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

In a Select Statement, how do you create a temporary column to display calc results?

Cleo Millet
P: 7
I know there is a way to create a temporary column as part of a basic Select Statement search that shows the result of mathematical calculations done in that search, but I can't remember the syntax and googling it has been a wash out.

I have a list of classes in a database. I need to list all classes with less than 12 students in them, that's fine. But I also need add a column that shows the number of students necessary to bring the class total up to 12.
Oct 19 '11 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,349
There's not really a syntax, you just put in the expression. If you want to give it a column name, you use the AS predicate, but that's optional.
Expand|Select|Wrap|Line Numbers
  1. SELECT col1, 
  2.    col2, 
  3.    col1 + col2 AS sumCol
  4. FROM table1
Oct 19 '11 #2

Post your reply

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