Advertisement
Guest User

Untitled

a guest
Feb 25th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. % Name: Bernard Ma
  2. % Last 5 of ASU ID: 20989
  3. % CSE412
  4. % Professor Davulcu
  5.  
  6. % Question 1
  7.  
  8. topCDs2003 := project cdCode(select rating >= 1 and rating <= 5 and year = 2003(topCDs));
  9. query1Ans := project cdCode, cdTitle, clientID, firstName, lastName, numberSold(((topCDs2003 njoin cd) njoin (rentedBy)) njoin client);
  10.  
  11. % Question 2
  12.  
  13. % Prints column of number sold for each cd published in 2003
  14. sold2003 := project numberSold(select year = 2003(cd));
  15.  
  16. % Creates a copy of the query above and renames the label 'numberSold' so there are no duplicate attributes
  17. sold2003v2 (numberSoldv2) := sold2003;
  18.  
  19. % Selects rows where sold2003 is smaller than sold2003v2. This nets all the unwanted rows (ones that aren't max)
  20. unwantedNonMaxRows := project numberSold(select numberSold < numberSoldv2 (sold2003 product sold2003v2));
  21.  
  22. % Subtracts the original column from the unwanted columns to net the maximum of the column
  23. sold2003Max := project numberSold(sold2003 difference unwantedNonMaxRows);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement