SQL Practice

advertisement
SQL Practice
The following questions refer to the next 2 tables that contain info about stocks and stock transactions:
STOCKS(Symbol, Name, SType)
TRADES(Symbol, TClose, PriorClose, ChangeClose, Volume, TMonth, TDayOfMonth, TYear, TDayOfWeek,
TQuarter)
Write SQL queries to produce the following results:
1. List the ChangeClose for NDX stock on Fridays.
2. List the minimum, maximum, and average ChangeClose for NDX stock on Fridays.
3. For the NDX stock, show the average ChangeClose value for each year. Show the year too.
4. For the NDX stock, show the average ChangeClose value grouped by year and month. Show the
year and month too.
5. For the NDX stock, show the difference between the maximum ChangeClose and the minimum
ChangeClose grouped by year, quarter and month, shown in the descending order of the
difference (you will need to give a name to the difference in order to sort by it). Show the year,
quarter and month too.
6. For the NDX stock, show the average ChangeClose grouped by year, shown in descending order
of the average. Show only groups for which the average is positive.
7. List all the dates in the TRADES table, in the format day/month/year (do not be concerned with
trailing blanks).
8. List the Symbol, Name, TClose, TMonth, TDayOfMonth, TYear for all the trade data for NDX
stock during 2008.
Download