Trying to get data to group.. but unsure of the group by function. I have a query as follows:
SELECT company FROM $which WHERE company='$type' GROUP BY company ORDER BY company ASC
Which gets the grouping done OK.
However what I would really like to get is below:
SELECT company,ref FROM $which WHERE company='$type' GROUP BY company ORDER BY company ASC
Which as you can tell, falls flat on its own query. So the question is this, how can I get both the company name and reference out, when I want to order by the company name when it has been grouped, without getting the message
Warning: MS SQL message: Column 'company.ref' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. (severity 16)
Running M$SQL Server 7
IIS 5
Cheers,