Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get all the records using CTE

Albert ChaoJun 10 2022
CREATE TABLE test_tab (
    col_name  VARCHAR2(20),
    log_time  TIMESTAMP(6),
    status    VARCHAR2(20)
);

INSERT INTO test_tab VALUES('Engineering','08-06-22 08:09:16.366000000 PM','UP');
INSERT INTO test_tab VALUES('Engineering','09-06-22 08:28:16.366000000 PM','UP');
INSERT INTO test_tab VALUES('Engineering','09-06-22 08:13:16.366000000 PM','DOWN');
INSERT INTO test_tab VALUES('Commerce','07-06-22 4:59:16.366000000 PM','DOWN');
INSERT INTO test_tab VALUES('Commerce','07-06-22 6:34:16.366000000 PM','UP');
INSERT INTO test_tab VALUES('Commerce','07-06-22 6:49:16.366000000 PM','DOWN');
INSERT INTO test_tab VALUES('Commerce','01-06-22 2:15:16.366000000 PM','UP');
INSERT INTO test_tab VALUES('Commerce','07-06-22 07:04:16.366000000 PM','UP');
COMMIT;

Tool used: Oracle Developer(18c)

I have one table test_tab in which there are multiple col_name values like 'Engineering', 'Commerce' etc just for testing purpose I have given two column names. I need to find out the start log time and end log time for particular col_name
Start_time logic : For particular col_name say 'Commerce' I need to check the minimum log time whose status is DOWN.
End_time logic: For the same col_name say 'Commerce' I need to check the start_time derived from above logic and see which is just greater than that time in status UP. That would be my end_time.
My attempt (Working only for 'Commerce'):

WITH a AS(
SELECT col_name,MIN(log_time)start_time
FROM test_tab WHERE status = 'DOWN'
GROUP BY col_name
),
b AS(
SELECT col_name,log_time end_time
    FROM( SELECT col_name,log_time,
        dense_rank() over (order by log_time asc)rnk
        FROM test_tab WHERE status = 'UP')
        WHERE rnk = 2
)
SELECT a.col_name,a.start_time,b.end_time FROM a
JOIN b ON(a.col_name = b.col_name);

But the above solution is not giving the result for 'Engineering'. It is just fetching details only for 'Commerce'
Expected Output:

Col_name    start_time                          end_time
Commerce    07-06-22 4:59:16.366000000 PM     07-06-22 6:34:16.366000000 PM
Engineering 09-06-22 08:13:16.366000000 PM    09-06-22 08:28:16.366000000 PM
This post has been answered by Frank Kulash on Jun 10 2022
Jump to Answer

Comments

Gaz in Oz

facebook develop and support that third paty mysql database engine myrocks.

You should read the information on the link you posted and the other links it points to, for example MyRocks | A RocksDB storage engine with MySQL | MyRocks , as it answers many of your questions. For example right at the top https://en.wikipedia.org/wiki/MyRocks t says:

MyRocks is open-source software developed at Facebook in order to use MySQL features with RocksDB implementations. It is based on Oracle MySQL 5.6.

An interesting feature of mysql is that one installation can support multiple and different database engines, so you could set it up with innodb AND rocksdb,

Answer

- What versions of Oracle MySQL support with MyRocks Storage Engine i.e. 5.6,5.7, 8.0?

Oracle does not support MyRocks

- Do Oracle MySQL provide technical support for MyRocks Storage Engine (on all or any specific MySQL version)?

Oracle does not support MyRocks

- Do we have all MySQL Enterprise Features available with MyRocks Storage Engine as we have with Innodb.

No.

- Do we have all MySQL enterprise edition encryption/decryption features (TDE, Innodb tablespace, column-level, a/symmetric key based etc.) available with MyRocks storage engine as well? ... as we have with Innodb storage engine.

No.

- Does MyRocks Storage Engine support Master-Master replication and HA/Clustering feature?

You could build that on top of MyRocks but that is something you would have to do.

If you really need MyRocks, contact your salesperson and let them know plus go to bugs.mysql.com and add you voice to the feature request.

Marked as Answer by Muhammad Nawaz · Sep 27 2020
1 - 2

Post Details

Added on Jun 10 2022
6 comments
236 views