sql statement help!

Results 1 to 2 of 2

Thread: sql statement help!

  1. #1
    Join Date
    Dec 1969

    Default sql statement help!

    *<BR>I have a table with year,each quarter and corresponding Revenue Amount.<BR>With my SQL as below , I get the following ..<BR><BR>SQLstr="Select RevenueYear,Quarter,RevAmount from Table1 where projectId=1"<BR><BR>output ******<BR><BR>Year Quarter Amount<BR>--------------------------<BR>1999 1 $20,000<BR>1999 2 $50,000<BR>2000 1 $30,000<BR><BR>Now I would like to find the yearly total for each year (summing up the quarters) and display in the above o/p.<BR>How would I modify the above SQl.<BR>Please Help!!<BR>Thanks,<BR>

  2. #2
    sqlphreak Guest

    Default RE: sql statement help!

    Use an aggregate:<BR><BR>SELECT year, SUM(amount) FROM Table1 GROUP BY year<BR><BR>will yield:<BR><BR>1999 $70,000<BR>2000 $30,000

Posting Permissions

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