Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to return total number of dates from this year? 1

Status
Not open for further replies.

NFLDUser

IS-IT--Management
Apr 17, 2006
47
CA
I have a table called PatientList that has a field called frst_visit that indicates when someone becomes a customer. How could I return the total number of customers that dates are from the current year, one year previous and 2 years ago. So I am looking to return 3 values.
 
Code:
select sum(iif(year(frst_visit)
             = year(date()),1,0))
           as visits_this_year
     , sum(iif(year(frst_visit)
             = year(date())-1,1,0))
           as visits_last_year
     , sum(iif(year(frst_visit)
             = year(date())-2,1,0))
           as visits_prev_year
  from PatientList

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top