my first query returns me the value 20:
SELECT numberofseats
from plane
where tail number in
( select flighttailnumberfk
from flight
where departuretime between '11/29/2014' and '11/30/2014' and
flightdepartureairportfk = 'jfk' and
flightarrivalairport = 'mli'
)
and my second query returns me 1:
select count(reservationseatfk)
from flight f, reservation r
where f.departuretime between '11/29/2014' and '11/30/2014' and
f.reservationflightidfk = f.flightid and r.reservationdeparturetimefk = f.departuretime
Now my problem is that I want to subtract the first query from the second query and give me the answer 19. how do i do that?
You could use sub sql to subtract
SELECT numberofseats - ( select count(reservationseatfk)
from flight f, reservation r
where f.departuretime between '11/29/2014' and '11/30/2014' and
f.reservationflightidfk = f.flightid and r.reservationdeparturetimefk = f.departuretime)
from plane
where tail number in
( select flighttailnumberfk
from flight
where departuretime between '11/29/2014' and '11/30/2014' and
flightdepartureairportfk = 'jfk' and
flightarrivalairport = 'mli'
)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments