index | search | no replies | posting guidelines | help login | register
Index » Programming Languages » SQL
search this forum:
:: Getting Records for a Fiscal Year ::    show all messagesPost a New Message | Post a Reply
Oct 15 2003, 4:02 PM
 Re: Getting Records for a Fiscal YearPost a Reply
 ghost

View this author's profile Send this author a private message Visit author's homepage

from: Washington, DC

SELECT *, 'FiscalYear' =
  CASE    WHEN ([Reporting Month] < 10) THEN [Reporting Year]-1
    ELSE [Reporting Year]
  END
INTO
#T1
FROM Visitation
WHERE [Reporting Year] IN (1999-1,1999,2000,2001,2002,2002+1)


SELECT SUM(Visitation) AS [Total Visits], FiscalYear FROM #T1
  WHERE FiscalYear IN (1999,2000,2001,2002)
  GROUP BY FiscalYear
  ORDER BY FiscalYear

DROP TABLE #T1


-------------------------
Ghost
Pages: (1)   [1]

search this forum: