Facebook
From asfdsaf, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 264
  1. -- zad 1
  2. /*SELECT* FROM Customers
  3. WHERE CompanyName LIKE 'C%'
  4. AND LEN(Country)>6;*/
  5.  
  6. -- zad2
  7. SELECT OrderId,
  8. (UnitPrice * Quantity * 1-Discount) as value
  9. from [Order Details];
  10.  
  11. --zad3
  12. /*SELECT OrderID , sum(UnitPrice * Quantity * 1-Discount) as value  
  13. from [Order Details]
  14. GROUP by OrderID;*/
  15.  
  16. --zad4
  17. /*SELECT OrderID,
  18. count(distinct productid)
  19. sum(UnitPrice * Quantity * (1-Discount))  as value  
  20. from [Order Details]
  21. GROUP by OrderID;*/
  22.  
  23. -- zad5
  24. --select distinct OrderID, round (sum(UnitPrice * Quantity * 1-Discount),2) as value from [Order Details] GROUP by OrderID order by value desc;
  25.  
  26. -- zad6
  27. --select SupplierID ,round(avg(UnitPrice),2) as value from Products GROUP BY SupplierID ORDER by value desc;
  28. --select SupplierID ,round(avg(UnitPrice),2) as value from Products GROUP BY SupplierID ORDER by SupplierID;
  29. --select SupplierID ,round(avg(UnitPrice),2) AvgPrice from Products GROUP BY SupplierID ORDER by AvgPrice ASC;
  30.  
  31. --zad7
  32. --select ProductID, ProductName, UnitPrice from Products where Discontinued=0 and UnitPrice<12;
  33.  
  34. --zad8
  35. --select sum(UnitPrice*UnitsInStock)from products;
  36.  
  37. --zad9
  38. /*select avg(unitprice)avgPrice
  39. from products
  40. group by categoryid
  41. having count(distinct ProductID)<10;*/
  42.  
  43. --zad10
  44. /*select categoryid,
  45. round(avg(unitprice),2) as srednia,
  46. round(min(unitprice),2) as minimum,
  47. round(max(unitprice),2) as maksimum
  48. from products
  49. group by CategoryID;*/
  50.  
  51. --zad11
  52. /*select 'DE_' +companyname nazwa from Customers where country ='Germany'
  53. Union
  54. select 'PL_' +companyname from Customers where country = 'Poland'
  55. union
  56. select 'USA_' +companyname from Customers where country ='USA'
  57.  
  58. order by nazwa;*/
  59.  
  60. https://put.blinkiewicz.pl/courses/bd_lab