Presentation is loading. Please wait.

Presentation is loading. Please wait.

Q1 - Show all the records in the basket ball player table select * from BSKT_BALL_PLAYER;

Similar presentations


Presentation on theme: "Q1 - Show all the records in the basket ball player table select * from BSKT_BALL_PLAYER;"— Presentation transcript:

1

2

3 Q1 - Show all the records in the basket ball player table select * from BSKT_BALL_PLAYER;

4 Q1 - answer

5 Q2 - Show the last name and first name of the players. select player_lname, player_fname From BSKT_BALL_PLAYER;

6 Q2 with alias select player_lname as "Last Name", player_fname as "First Name" from BSKT_BALL_PLAYER;

7 Q3 -Order the above by descending lname then descending first name select player_lname, player_fname from BSKT_BALL_PLAYER order by player_lname DESC, player_fname DESC ;

8 Q3 - output

9 Q4 - Add the GPA to the output and sort the output by GPA only. select player_lname, player_fname, gpa from BSKT_BALL_PLA YER order by gpa;

10 Q5 - Show the unique graduation years of all the players. select distinct year_graduation from BSKT_BALL_PLAYER;

11 What if I don’t use the keyword distinct? Some of the values are duplicated, like 2009, 2010, 2009… Number of records goes from 13 to 19

12 Q6 - Show the player’s first and last name and college if the college is 1. Order the output by player’s last name. select player_fname, player_lname, college from BSKT_BALL_PLAYER where COLLEGE = 1 order by player_lname;

13 Q 6 answer

14 But is college_id what they are looking for? select player_fname, player_lname, college_name, college_id from BSKT_BALL_PLAYER, college where COLLEGE = 1 and college = college_id order by player_lname;

15 Q6 answer revised

16 Q7 - Show the player’s first and last name, college, gpa if the college is 1 and the student’s GPA is greater than 3.5. Order the output by player’s last name.

17 No QC

18 With QC

19 Q 8 - Show the player’s first and last name, college, gpa if the college is 1 and the student’s GPA is greater than 3.5 OR the student’s jersey is #13 Order the output by player’s last name.

20 Key to this one…  Make sure to add parentheses!!!!

21

22 Q 9 Display the player’s first and last name, college, gpa if the college is 1, 2, 3, 4, or 5. Order the output by player’s last name.

23 Remember the in operator select player_fname, player_lname, college_name gpa, jersey_number, college from BSKT_BALL_PLAYER, college where COLLEGE in (1, 2, 3, 4, 5) and college = college_id order by player_lname; OR select player_fname, player_lname, college_name, gpa, jersey_number, college from BSKT_BALL_PLAYER, college where COLLEGE = 1 or college =2 or college =3 or college = 4 or college= 5 and college = college_id order by player_lname;

24 Q10 Show the players’ names born between 1/1/1984 and 3/5/1986. Order by player last name.

25 Remember the to_date function! select player_fname, player_lname, dob from BSKT_BALL_PLAYER where dob between to_date ('01/01/1984', 'mm/dd/yyyy') and to_date ('03/05/1986', 'mm/dd/yyyy') order by player_lname;

26 Q 11 Display the player’s first and last name, college, and gpa if the college is Temple University. Order the output by player’s last name.

27 select player_fname, player_lname, college, gpa, jersey_number from BSKT_BALL_PLAYER, college where COLLEGE_name = 'Temple University' and COLLEGE_ID= COLLEGE order by player_lname;


Download ppt "Q1 - Show all the records in the basket ball player table select * from BSKT_BALL_PLAYER;"

Similar presentations


Ads by Google