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 |
|
AhmetEmre90
Starting Member
5 Posts |
Posted - 2011-06-16 : 09:44:08
|
| i have to do these queries for homework, i wrote these quaries but they are not working properly. can anyone correct the queries.* Find all employees in the database who live in the same cities as the companies for which they work."select works.ename, company.cname, employee.city from works, company, employee where company.city=employee.city"* Find all employees who earn more than the average salary of all employees of their company."select ename from works group by cname " + "having salary > (select avg(salary) " + " from works where cname=works.cname)"* Find the company that has the most employees."select cname from works group by ename having count(ename)>= count(ename)"* Find the company that has the smallest payroll."select min(sum_payroll),cname from ( select sum(salary) as sum_payroll from works group by cname ),works"( i dont english very well, sorry if i have mistakes )http://ahmetemremermer.com |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2011-06-16 : 10:00:42
|
| hard to help without all the information we need. Follow the "How to ask" link.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
AhmetEmre90
Starting Member
5 Posts |
Posted - 2011-06-16 : 10:27:55
|
| sorry i forgot to post tbName and ColumnsTable_Name ( Columns )manages ( mname , ename )works ( ename , cname , salary )company ( cname , city )employee ( ename , street , city )http://ahmetemremermer.com |
 |
|
|
|
|
|
|
|