469,636 Members | 1,682 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

get grand total

232 100+
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"
  4.  
  5. FROM school
this query has error
Sep 18 '09 #1
3 3130
Atli
5,058 Expert 4TB
Hi.

What error are you getting?

How exactly does your table look like?
(The relevant parts of it, at least.)
Sep 18 '09 #2
kkshansid
232 100+
table is like this
schoolid,schoolname,2001(grant),2002(grant)
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
Atli
5,058 Expert 4TB
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.

Similar topics

2 posts views Thread by Bytesmiths | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.