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 |
tofoo
Starting Member
3 Posts |
Posted - 2015-04-10 : 08:45:11
|
Hello, I am new on the forum, i do a sql exercise and a wish to have advice.Here is the BDD (sorry for the quality)http://imagesia.com/test-sql_wjelQuestion 1 : Write SQL to show details of manager who manages more than 3 employeesMy answer : select * from employees em, job_history jh, departments depwhere jh.employees_ID=em.employees_IDand jh.end_data is null and dep.manager_ID=em.manager_IDhaving (em.employees_ID)>3;Question 2 : Write SQL to show country name, city and number of departments where department has more than 5 employeesMy answer : select co.country_name, lo.city, lo.postal_codefrom countries co, locations lo, employees em, departments depwhere co.countries_ID=lo.countries_IDand lo.location_ID=dep.location_IDand dep.manager_ID=em.manager_IDhaving (em.employees_ID)5;Question 3 : Write SQL to show the details of employees drawing the highest salary in the departmentMy answer : select em.*, jo.jobs_titlesfrom employees em, jobs jowhere em.job_ID=k=jo.em.job_IDand max(max_salary);Question 4 : Write SQL to show employee name, job title, start date and end date of past jobs of all employees with commission percentage nullMy answer : select em.first_name,em.last_name, jo.jobs_titles, jh.start_date, jh.end_datefrom employees em, jobs jo, job_history jhwhere em.commission_pct is null;Thanks ! |
|
tofoo
Starting Member
3 Posts |
Posted - 2015-04-11 : 12:40:56
|
Anyone please ? |
|
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2015-04-11 : 17:03:34
|
First of all, try executing your queries. That way you'll see if it works, and even if it doesn't, the error message will point you in the direction of, what might be wrong.Secondly, you will probably want to look into the terms "group by" and subqueries.Lastly, do you self a favour and read up on the different ways of joining tables. |
|
|
tofoo
Starting Member
3 Posts |
Posted - 2015-04-12 : 07:48:56
|
Hello bitsmed,It's a paper exercise so i can't execute the query.I want external opinion to see if i am in the good direction. |
|
|
|
|
|
|
|