Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kkuntz
Starting Member
2 Posts |
Posted - 2011-02-27 : 22:43:19
|
| Having trouble with a few HW questions and new to SQLThis is the question:9. Create a query that lists players (player_name), their current Salary and a new (created) column that reflects a 10% increase in Salary (calculated as Salary * 1.1). Sequence the data in descending sequence by salary.This is the code I have: SELECT player_name, player_salary, (player_salary * 1.1) as updated_salary FROM players;I cannot find the syntax anywhere. If someone would be willing to help I would appreciate it very much. I also have a few more questions if anyone is feeling generous tonight |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2011-02-27 : 23:03:08
|
| SELECT player_name, player_salary, (player_salary * 1.1) as updated_salary FROM playersOrder by player_salary desc |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2011-02-27 : 23:04:52
|
quote: Originally posted by kkuntzI also have a few more questions if anyone is feeling generous tonight
If we see attempt from your side then we will help you in filling the gaps. |
 |
|
|
kkuntz
Starting Member
2 Posts |
Posted - 2011-02-27 : 23:20:42
|
| Thank you, here's another one that I can't figure out. 7.A query that lists all teams that have more than 4 players (in the player table). Include the columns team_id, team_name and the count of players for that team. code: SELECT team_id, team_name, COUNT(players.player_id) AS team_count FROM players, teams WHERE // filter by NHL teams that have more than 4 players with the same team_id value |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2011-02-27 : 23:34:46
|
quote: Originally posted by kkuntz Thank you, here's another one that I can't figure out. 7.A query that lists all teams that have more than 4 players (in the player table). Include the columns team_id, team_name and the count of players for that team. code: SELECT team_id, team_name, COUNT(players.player_id) AS team_count FROM players, teams WHERE // filter by NHL teams that have more than 4 players with the same team_id value
Hint: You have to use "group by" and " having " clause. |
 |
|
|
|
|
|
|
|