Displaying Dynamic Data using Sysdate - Oracle SQL -


is possible return fno column results data when data in column null?

current code:

select a.sno, a.tcode, a.fno airplane a, scheduled_flight s a.fno = s.fno or sdt >= trunc(sysdate);  

example output oracle sql:

sno     tcode                          fno ------- ------------------------------ ------- 0000001 a320 0000002 a320                           va12190 0000003 a330                           va82716 0000004 a330                           va82723 0000005 a330                           va82722 0000006 a330                           va82123 0000007 a330 0000001 a320 0000002 a320                           va12190 0000003 a330                           va82716 0000004 a330                           va82723  sno     tcode                          fno ------- ------------------------------ ------- 0000005 a330                           va82722 0000006 a330                           va82123 0000007 a330 0000001 a320 0000002 a320                           va12190 0000003 a330                           va82716 0000004 a330                           va82723 0000005 a330                           va82722 0000006 a330                           va82123 0000007 a330 0000002 a320                           va12190  sno     tcode                          fno ------- ------------------------------ ------- 0000004 a330                           va82723 0000006 a330                           va82123 

i want display results in flight number (fno) column flights scheduled today. other flights, not scheduled today, should return null value in fno column, whilst still listing flights. appreciated new sql.

edit: output when removing where sdt >= trunc (sysdate); show sno below fno of sno 0000003 , 0000005. not other flights not scheduled today.

sql> select a.sno, a.tcode, a.fno   2    airplane left outer join scheduled_flight s on a.fno = s.fno;  sno     tcode                          fno ------- ------------------------------ ------- 0000001 a320 0000002 a320                           va12190 0000003 a330                           va82716 0000004 a330                           va82723 0000005 a330                           va82722 0000006 a330                           va82123 0000007 a330  7 rows selected. 

edit 2:

 select a.sno, a.tcode, a.fno   2    airplane left outer join scheduled_flight s on a.fno = s.fno   3   , sdt >= trunc (sysdate)   4   order a.sno;  sno     tcode                          fno ------- ------------------------------ ------- 0000001 a320 0000002 a320                           va12190 0000003 a330                           va82716 0000004 a330                           va82723 0000005 a330                           va82722 0000006 a330                           va82123 0000007 a330 

edit 3: display following.

sno     tcode                          fno ------- ------------------------------ ------- 0000001 a320 0000002 a320                            0000003 a330                           va82716 0000004 a330                            0000005 a330                           va82722 0000006 a330                            0000007 a330 

edit 4: can group sdt , show fno shown sdt's?

sno     tcode                          fno     sdt ------- ------------------------------ ------- -------------------- 0000001 a320 0000002 a320                           va12190 0000003 a330                           va82716 11/sep/2017 21:59:00 0000004 a330                           va82723 0000005 a330                           va82722 11/sep/2017 14:00:00 0000006 a330                           va82123 0000007 a330 

you must use left join

select a.sno, a.tcode,s.fno     airplane left outer join scheduled_flight s on a.fno = s.fno 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -