Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. -- 01 ORACLE
  2.  
  3. -- WHERE:
  4. Select c.companyname, o.orderdate, e.lastname
  5. From orders o, customers c, employees e
  6. Where o.customerid=c.customerid and
  7. o.employeeid=e.employeeid;
  8.  
  9.  
  10.  
  11. -- FROM:
  12. Select companyname, orderdate, lastname
  13. From orders o
  14. Join customers c
  15. On o.customerid=c.customerid
  16. Join employees e
  17. On o.employeeid=e.employeeid;
  18.  
  19.  
  20.  
  21. -- 02 ORACLE
  22.  
  23. -- WHERE:
  24. Select o.orderdate, q.quantity, p.productname
  25. From Orders o, Orderdetails q, products p
  26. Where o.orderid=q.orderid and q.productid=p.productid;
  27.  
  28.  
  29. -- FROM:
  30. Select orderdate, quantity, productname
  31. From orders o
  32. Join orderdetails q
  33. On o.orderid=q.orderid
  34. Join products p
  35. On q.productid=p.productid;
  36.  
  37.  
  38.  
  39. -- 03 ORACLE
  40.  
  41. -- WHERE:
  42. Select p.productname, c.categoryname, sum(o.quantity) as "Total Quantity"
  43. From Products p, Categories c, Orderdetails O
  44. Where p.categoryid = c.categoryid and p.productid = o.productid
  45. Group By Productname, Categoryname
  46. Order By sum(quantity) desc;
  47.  
  48.  
  49. -- FROM:
  50. Select Productname, categoryname, sum(quantity) as "Total Quantity"
  51. From Products p
  52. Join Categories c
  53. On p.categoryid = c.categoryid
  54. Join Orderdetails o
  55. On p.productid = o.productid
  56. Group By Productname, categoryname
  57. Order By sum(quantity) desc;
  58.  
  59.  
  60.  
  61. -- 04 ORACLE
  62.  
  63. -- WHERE:
  64. Select e.Lastname, t.TerritoryDescription, r.RegionDescription
  65. From Employees e, Territories t, Region r, Employeeterritories i
  66. Where t.regionid = r.regionid and i.territoryid = t.territoryid and e.employeeid = i.employeeid
  67. Order By Lastname;
  68.  
  69.  
  70.  
  71. -- FROM:
  72. Select Lastname, TerritoryDescription, RegionDescription
  73. From Territories t
  74. Join Region r
  75. On t.regionid = r.regionid
  76. Join Employeeterritories i
  77. On i.territoryid = t.territoryid
  78. Join Employees e
  79. On e.employeeid = i.employeeid
  80. Order By Lastname;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement