-
View : name + count GROUP BY
Hi
for MS SQL 2000/2500
I am having a table with Products, a Product be many time in the table
I need a view to return a GROUP BY on Name + Reference and the Count(Name)
Product
Product_ID int NOT NULL,
Name varchar (50) Not Null,
Reference varchar (50) Not Null,
Infos varchar (255) Null,
PDate (smalldatetime) Null
I need a View with 4 columns
MAX(Product_ID) AS ID, Name, Reference, Count(Name) AS Ct
GROUP BY Name, Reference
i can't Get the count in the same view
thank you for helping
-
Aggregate function applies to all columns in group, so you can't do count(name), you have to use count(*)
-
it works fine !
thank you
Last edited by anselme; 11-22-2006 at 04:27 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|