Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Re:How to Group the recordset into single record

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2009-04-01 : 21:46:06
Dear All,

My TableName: TGPVList
Membercode|RankID|PPV|TGPV|Downline1|Downline2|Downline3|Downline1GPV|Downline2GPV|Downline3GPV
MYS00000000|100|307.5|1020306|MYS00000118|0|0|181812|
MYS00000000|100|307.5|1020306|MYS00000001|607275.5|0|0
MYS00000000|100|307.5|1020306|MYS00000115|0|230856|0
MYS00000001|100|500|607275.5|MYS00000005|0|579469|0
MYS00000001|100|500|607275.5|MYS00000002|8991.5 0|0


Output that required:-
Membercode|RankID|PPV|TGPV|Downline1|Downline2|Downline3|Downline1GPV|Downline2GPV|Downline3GPV
MYS00000000|100|307.5|1020306|MYS00000001|MYS00000115|MYS00000118|607275.5|230856|181812
MYS00000001|100|500|607275.5|MYS00000002|MYS00000005|8991.5|579469|0


I have table structure- Tablename:TGPVList.
I want to group the data for same membercode into a single line as mention above. Can anyone here help on the sql statement?

Thank You & Appreciate for your help.

Regards,
Micheale

micnie_2020
Posting Yak Master

232 Posts

Posted - 2009-04-02 : 00:19:30
Thank You.

I got the answer from this forumn itself-Topic called Want an unique result replied by tkizer .

The answer is used method

select compid,max(department) as department,max(address) as address,max(city) as city,zip
from @temp group by compid,zip

Thank you.

God bless you.

Regards,
Michelle
Go to Top of Page
   

- Advertisement -