Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Name: Bernard Ma
- % Last 5 of ASU ID: 20989
- % CSE412
- % Professor Davulcu
- % Question 1
- topCDs2003 := project cdCode(select rating >= 1 and rating <= 5 and year = 2003(topCDs));
- query1Ans := project cdCode, cdTitle, clientID, firstName, lastName, numberSold(((topCDs2003 njoin cd) njoin (rentedBy)) njoin client);
- % Question 2
- % Prints column of number sold for each cd published in 2003
- sold2003 := project numberSold(select year = 2003(cd));
- % Creates a copy of the query above and renames the label 'numberSold' so there are no duplicate attributes
- sold2003v2 (numberSoldv2) := sold2003;
- % Selects rows where sold2003 is smaller than sold2003v2. This nets all the unwanted rows (ones that aren't max)
- unwantedNonMaxRows := project numberSold(select numberSold < numberSoldv2 (sold2003 product sold2003v2));
- % Subtracts the original column from the unwanted columns to net the maximum of the column
- sold2003Max := project numberSold(sold2003 difference unwantedNonMaxRows);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement