Guest User

Untitled

a guest
Jan 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. SELECT description
  2. FROM l_foods
  3. WHERE price BETWEEN 1.00 AND 2.00
  4. ORDER BY description
  5.  
  6. SELECT description
  7. FROM l_foods
  8. WHERE (price >= (select min_price from sec0306_price_constants )
  9. AND price <= (select max_price from sec0306_price_constants ))
  10. ORDER BY description
  11.  
  12. declare @constants table (typ varchar(10), minprice float, maxprice float)
  13.  
  14. insert into @constants values
  15. ('dirtcheap', 0.00, 0.99),
  16. ('justright', 1.00, 2.00),
  17. ('expensive', 2.01, 10.00)
  18.  
  19. select description
  20. from l_foods f, @constants c
  21. where f.price >= c.minprice and f.price <= c.maxprice
  22. and c.typ = 'justright'
  23.  
  24. --BEGIN PROC
  25.  
  26. DECLARE @MINPRICE DECIMAL;
  27. DECLARE @MAXPRICE DECIMAL;
  28.  
  29. SELECT
  30. @MINPRICE = min_price,
  31. @MAXPRICE = max_price
  32. FROM
  33. sec0306_price_constants;
  34.  
  35. SELECT description
  36. FROM l_foods
  37. WHERE
  38. price BETWEEN @MINPRICE AND @MAXPRICE
  39. ORDER BY description
Add Comment
Please, Sign In to add comment