Question : Comparing the latest date

Hello Gurus,
Can i write a query to pull the nearest date i.E
 tableA.seq.no             tableA. ord_dt                        tableB. Coll_dt            tableB.seq.no
   101                            05-10-2010                             02-10-2010                    101
   101                            05-10-2010                             03-10-2010                    101
   101                            05-10-2010                             04-10-2010                     101
   101                            05-10-2010                             06-10-2010                    101
I have the oracle DB.
ord_dt is coming from table A and coll_dt is coming from table B. I have to write the SQL where
I have to compare the Ord_dt to the nearest coll_dt and the condition is coll_dt should be less then ord_dt.
In the Above case the final result should look like
tableA.seq.no              tableA. ord_dt                      tableB. Coll_dt                tableB.seq.no
      101                           05-10-2010                          04-10-2010                       101
Is there any Sql work around this?

Answer : Comparing the latest date

Try this:

If you want to fetch more columns, then kindly post the entire query so that we can fix it out..
1:
2:
3:
4:
SELECT tableA.seq_no, tableA.ord_dt, MAX(tableB.Coll_dt) as col1_dt
FROM tableA inner join tableB on tableA.seq_no = tableB.seq.no
WHERE tableA.ord_dt <= tableA.ord_dt
GROUP BY tableA.seq_no, tableA.ord_dt
Random Solutions  
 
programming4us programming4us