adspace
Table 1: col1 Timestamp
----------------
01-mar-2012 11:12:46
Table 2: col2 Timestamp
--------------------
01-mar-2012 11:12:10
01-mar-2012 11:11:23
Write a query to display a row with table2 col2 value less
than tabl1 col1 value. Maximum timestamp value previous to
table1 col1 value.
Display a result as:
Col1 col2
----- -----
01-mar-2012 11:12:46 01-mar-2012 11:12:10
Answer Posted / Subhash Kumar Maurya
WITH latest AS ( SELECT MAX(col1) as max_date FROM your_table1 ), older AS ( SELECT * FROM your_table2 WHERE col2 < (SELECT max_date FROM latest) ORDER BY col2 DESC LIMIT 1 ) SELECT col2 FROM older;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the current version of postgresql?
Can we rollback truncate?
How do I remove duplicates in two columns?
how to use regular expression in pattern match conditions? : Sql dba
what is dbms? : Sql dba
Is primary key clustered index?
how to start mysql server? : Sql dba
how many tables will create when we create table, what are they? : Sql dba
Do we need to rebuild index after truncate?
what are the advantages of sql ? : Sql dba
Is primary key always clustered index?
What is your daily office routine?
Hi am new to PLSQL & facing problems in writing code like in SP, Functions, so any one having some SP coding with in depth explanation please share with me my Email ID suvarnaatsuvarna@rediffmail.com Or taking tanning on this please do contact me
Can delete statement be rollbacked?
define sql insert statement ? : Sql dba