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)
 Please sovle this problem?

Author  Topic 

whitebird
Starting Member

12 Posts

Posted - 2008-01-21 : 08:40:38
Hi,
I have a sql result like this.
SalesPersonId , ProductId.
1 10
1 10
1 11
1 12
2 10
2 11
3 10
3 10

i want the sql query to display output like this.

1 3
2 2
3 1

Please give me the sql query as soon as possible.

Regards,
Whitebird
Raghu sunkara,

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-01-21 : 08:54:48
[code]Select SalesPersonID, count(distinct ProductID) as Prod_Count
From Table
Group by SalesPersonID[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-01-26 : 12:27:57
quote:
Pease give me the sql query as soon as possible.


in the middle of an exam, whitebird?

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -