Advertisement
Inverth

some-query-from-lecture

Dec 1st, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.74 KB | None | 0 0
  1. select Car.*
  2. from Car
  3. where CarN not in (
  4.         select CarN
  5.         from [Contract]
  6.         where year([GetDate]) = year(getdate())
  7.     );
  8.  
  9. select distinct
  10.     Offcode,
  11.     City,
  12.     Addr
  13. from
  14.                [Office]   as O
  15.     inner join [Contract] as C on O.RecN = C.RetRecN
  16. where
  17.     CarN not in (
  18.         select CarN
  19.         from [Contract]
  20.         where GetRecN = C.GetRecN
  21.     )
  22.  
  23. select
  24.     Offcode,
  25.     RegNum
  26. from
  27.                [Office]
  28.     cross join [Car]
  29.     except (
  30.         select
  31.             Offcode,
  32.             RegNum
  33.         from
  34.                        [Office]   as O
  35.             inner join [Contract] as C   on O.RecN = C.GetRecN
  36.             inner join [Car]      as car on car.CarN = c.CarN
  37.     )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement