How do I count only once

This is a discussion on How do I count only once within the sqlserver-faq forums in Microsoft SQL Server category; Hi, I have a name of a person that particiaopte in one or many meeting at different date of the year Name Title Meeting date Eric Rose Reporter 2 feb 2008 Eric Rose Reporter 5 may 2008 I have difficulty in listing name of person only once by grouping into Quarter. If I group the above into fiscal year, then Eric Rose shaow only once but If I group into Quarter, than Eric Rose list once in the first and once in the second quater. How do I count Eric Rose only once in the first querter? SF...

Go Back   Database Forum > Microsoft SQL Server > sqlserver-faq

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-27-2008, 05:48 AM
Default How do I count only once

Hi,

I have a name of a person that particiaopte in one or many meeting at
different date of the year

Name Title Meeting date

Eric Rose Reporter 2 feb 2008
Eric Rose Reporter 5 may 2008

I have difficulty in listing name of person only once by grouping into
Quarter. If I group the above into fiscal year, then Eric Rose shaow only
once but If I group into Quarter, than Eric Rose list once in the first and
once in the second quater. How do I count Eric Rose only once in the first
querter?

SF


Reply With Quote
  #2  
Old 08-27-2008, 08:16 AM
Default Re: How do I count only once

Try:

select
[Name]
, count (distinct (datepart (qq, [Meeting date]))
from
Myable
group by
[Name]

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau


"SF" wrote in message
news:%23Ca60DCCJHA.4884-at-TK2MSFTNGP02.phx.gbl...
Hi,

I have a name of a person that particiaopte in one or many meeting at
different date of the year

Name Title Meeting date

Eric Rose Reporter 2 feb 2008
Eric Rose Reporter 5 may 2008

I have difficulty in listing name of person only once by grouping into
Quarter. If I group the above into fiscal year, then Eric Rose shaow only
once but If I group into Quarter, than Eric Rose list once in the first and
once in the second quater. How do I count Eric Rose only once in the first
querter?

SF


Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 05:23 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.