sql problems

Results 1 to 2 of 2

Thread: sql problems

  1. #1
    Join Date
    Dec 1969

    Default sql problems

    I am using SQL Server 7 and I am having trouble with an SQL Query. It is not giving me the results I want. Here is my query:<BR><BR>SELECT Year(Date) AS YearNumber, COUNT(Date) AS Total FROM Stats group by Date<BR><BR>Right now that query will show various totals for 2000,2001.<BR><BR>Is there a way to either:<BR>a) get 2 unique years(2000,2001) with totals<BR>b) sum both years up with sql<BR><BR>Matt

  2. #2
    Join Date
    Dec 1969

    Default RE: sql problems

    Try this query,<BR><BR>SELECT DISTINCT Year(Date) AS YearNumber,<BR>(SELECT count(total) FROM Stats s2 WHERE year(s2.date) = year(s1.date))<BR>FROM Stats s1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts