472,127 Members | 1,499 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

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 3244
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.