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
 General SQL Server Forums
 New to SQL Server Programming
 Grouping and filtering data

Author  Topic 

A. Kucuk
Starting Member

2 Posts

Posted - 2010-05-06 : 04:34:20
Removed on request

apodemus
Starting Member

30 Posts

Posted - 2010-05-06 : 04:52:20
try to use count(distinct snumber)

SELECT RelatieId, Jaar, Sofinummer, (select COUNT(distinct Sofinummer) from Leaseproces.dbo.Relatie_BDVeld RB where RelatieId = Leaseproces.dbo.Relatie_BDVeld.RelatieId and Jaar = Leaseproces.dbo.Relatie_BDVeld.Jaar)

FROM Leaseproces.dbo.Relatie_BDVeld
GROUP BY RelatieId, Jaar, Sofinummer

apodemus
Go to Top of Page

apodemus
Starting Member

30 Posts

Posted - 2010-05-06 : 04:53:57
or if you don't need info about Sofinummer/snumber you can query

SELECT RelatieId, Jaar, COUNT(distinct Sofinummer)
FROM Leaseproces.dbo.Relatie_BDVeld
GROUP BY RelatieId, Jaar

apodemus
Go to Top of Page

A. Kucuk
Starting Member

2 Posts

Posted - 2010-05-06 : 05:57:08
edit: removed on request
Go to Top of Page

apodemus
Starting Member

30 Posts

Posted - 2010-05-06 : 07:35:17
you're welcome

apodemus
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-04 : 04:19:48
quote:
Originally posted by A. Kucuk

Removed on request


who request you to remove the original question?


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -