Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

GROUP BY clause and table join

$
0
0

This is probably simple but I’m just trying to learn SQL. I have two tables.

employee table;

Fname

Lname

Dno

John

Smith

5

Franklin

Wong

5

Joyce

English

5

Ramesh

Narayan

5

James

Borg

1

Jennifer

Wallace

4

Ahmad

Jabbar

4

Alicia

Zelaya

4

department table;

dnumber

dname

1

Headquarters

2

Development

3

Sales

4

Administration

5

Research

I’m try to use GROUP BY and table join to get the department name “dname” and the COUNT of the employees in each department that has a COUNT of more than 3 employees. If I use:

SELECT dname, COUNT(employee.dno)

FROM employee

INNER JOIN department ON department.dnumber = employee.dno

WHERE COUNT(employee.dno)>3

GROUP BY dname;

I get: Invalid use of group function

Thanks for help.


why767


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>