English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

does not work either

2006-11-10 02:15:17 · update #1

3 answers

Rowcount instead of count.

2006-11-10 02:23:44 · answer #1 · answered by ash 2 · 0 0

I don't quite understand your statement of "... the count of 1 field", that does not make sense. But anyway, you have to understand that COUNT(employee_id) is an 'aggregate function' giving you results of a 'group' of records. In this case you are not using 'group by' but nevertheless it is still an aggregate over the entire Employees table. So if you want the COUNT(*) of all rows in the Employees table along with all field (*) for each row of the employees table (which by the way would be the same for each row returned since it's a count of all records in the table) you could do:

SELECT *,
(SELECT COUNT(*) FROM Employees) AS EmployeeCount
FROM Employees

2006-11-10 11:26:01 · answer #2 · answered by TBone 2 · 0 0

I think I understand what you're trying to get. Try this:

SELECT employee_count, * FROM
Employees LEFT OUTER JOIN
(SELECT COUNT(*) AS employee_count, employee_id FROM
Employees group by employee_id) as q1 ON
Employees.employee_id=q1.employee_id

2006-11-13 12:24:17 · answer #3 · answered by boredatwork 2 · 0 0

fedest.com, questions and answers