Sql query
-
If table1 has fields Studentname , departmentid and table2 has fields departmentid,departmentname then can anyone give me the sql query to get the department name and the number of students in each department.
-
If table1 has fields Studentname , departmentid and table2 has fields departmentid,departmentname then can anyone give me the sql query to get the department name and the number of students in each department.
-
If table1 has fields Studentname , departmentid and table2 has fields departmentid,departmentname then can anyone give me the sql query to get the department name and the number of students in each department.
Try this
SELECT Studentname , departmentid
FROM TABLE1 T1 INNER JOIN TABLE2 T2 ON
T1.departmentid = T2.departmentid
ORDER BY departmentidHope it helps
Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswam@its.co.za
-
Try this
SELECT Studentname , departmentid
FROM TABLE1 T1 INNER JOIN TABLE2 T2 ON
T1.departmentid = T2.departmentid
ORDER BY departmentidHope it helps
Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswam@its.co.za
Vuyiswa Maseko wrote:
Try this SELECT Studentname , departmentid FROM TABLE1 T1 INNER JOIN TABLE2 T2 ON T1.departmentid = T2.departmentid ORDER BY departmentid
The OP wants department name and count of students - your query returns neither. ;P
-
If table1 has fields Studentname , departmentid and table2 has fields departmentid,departmentname then can anyone give me the sql query to get the department name and the number of students in each department.
Thank u , just what I needed. select deptname,COUNT(deptid) from emp,department where emp.deptid =department.id group by deptname