By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

get grand total

P: 232
how to get grand total of two years 2001,2002 are fields
Expand|Select|Wrap|Line Numbers
  1. SELECT sum( 2001 ) AS "2001-2002", sum( 2002 ) AS "2002-2003", (
  2. "2001-2002" + "2002-2003"
  3. ) AS "grand total"
  5. FROM school
this query has error
Sep 18 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 5K+
P: 5,058

What error are you getting?

How exactly does your table look like?
(The relevant parts of it, at least.)
Sep 18 '09 #2

P: 232
table is like this
i want to get total grant of 2001 then i want to get total grant of 2002 then grant total of both totals (tot2001+tot2002)
all three in same row
Sep 22 '09 #3

Expert 5K+
P: 5,058
How about the error?
What exactly is going wrong with the query?

You should keep in mind tho, that in a query like that, numbers will not be interpreted as column names. If you have column names that are numbers, they must be enclosed in back-ticks (`).

Also, you can not use the aliases for the first two columns to get the sum for the third one. You would have to use the actual column names.
Sep 22 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.