December 4th, 2012, 11:11 AM
Join Date: Dec 2012
Time spent in forums: 43 m 57 sec
Reputation Power: 0
Modifying COUNT(*) statement for multiple tables - Please advise.
I need some advice modifying my existing COUNT(*) statement. I only have a basic knowledge of SQL, any advice would be greatly appreciated.
The COUNT(*) function displays the number of rows with column "attribute_23" populated for each "assignment_number". I am only interested in assignment_numbers with more than one row.
The following query achieves this....
SELECT assignment_number, COUNT(*) number_recs
WHERE attribute23 IS NOT NULL
GROUP BY assignment_number HAVING COUNT(*) >1
However, I want to add a "name" column from a 2nd table and "department" from a 3rd table to correspond with the assignment_number. person_id can be used to join the tables as it is present in each.
COUNT(*) does not need to be carried out on the additional "name" and "department" columns, i just want to add this information to my current results.
What is the best method of carrying out a COUNT(*) with multiple tables?
Advice would be greatly appreciated. Thanks
Last edited by TEABAG : December 4th, 2012 at 01:41 PM.