Link to home
Create AccountLog in
Avatar of TECH_NET
TECH_NET

asked on

Help with Group By clauses

I have a sql statement as follows:

SELECT USER_REGISTRATION_ID,DEALS_NAME,VENDOR_NAME,PROCESS_DATE FROM NOTIFYDEALS_LOGISTICS_VIEW GROUP BY USER_REGISTRATION_ID

I wish to get the following output.

Generate a list that is grouped by user_registeration  and get the total count (based on the no of occurrance of the user_registration-id in the table), Also i wish to retrieve the remaider of the columns.

Avatar of TECH_NET
TECH_NET

ASKER

I first part was achieved by the following query
SELECT USER_REGISTRATION_ID,Sum(USER_REGISTRATION_ID) FROM NOTIFYDEALS_LOGISTICS_VIEW GROUP BY USER_REGISTRATION_ID
but how do i get the remainder of the column and still show the aggregrate
ASKER CERTIFIED SOLUTION
Avatar of SQL_SERVER_DBA
SQL_SERVER_DBA
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I have 3 records and all the record show up but i do not see the count showing up with the right value. Since all the 3 records are for the same USER, (ie USER_REGISTRATION_ID =1)
the resultant should be 3 records showing the count column value (ie idcnt) as 3.