Bunich

Lab 3

Apr 17th, 2018
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT delivererid,MAX(DATA),MIN(DATA)
  2. FROM penalties
  3. GROUP BY delivererid
  4. HAVING COUNT(*)>=2;
  5.  
  6. SELECT p.delivererid, p.DATA, p.amount
  7. FROM(
  8.       SELECT delivererid,MAX(DATA) DATA
  9.       FROM penalties
  10.       GROUP BY delivererid) mdata, penalties p
  11. WHERE p.delivererid=mdata.delivererid AND mdata.DATA=p.DATA;
  12.  
  13. SELECT companyid
  14. FROM companydel
  15. WHERE numdeliveries>=1 OR numcollections>=1
  16. GROUP BY companyid
  17. HAVING (10/3)*COUNT(*)>=(SELECT COUNT(*)
  18.                   FROM deliverers);
RAW Paste Data