Click here to Skip to main content
15,894,241 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My table emp
SQL
create table emp(sal number,comm number);

Query
SQL
select sal,comm,sum(sal+comm) into total from emp where comm is not null;

Emp table has two columns 'sal' and 'comm'. I want to display sal and comm as well as total of sal and comm whose comm is not null but I'm getting error for above query.
Posted
Updated 4-Feb-15 19:54pm
v3
Comments
Tomas Takac 5-Feb-15 1:49am    
Why the SUM()? Isn't juts sal+con what you want? Can you show a sample of the output you expect?
sunnykvinod 5-Feb-15 1:51am    
sal comm total
.................
4000 3000 7000
6777 1000 7777
sunnykvinod 5-Feb-15 2:07am    
thank you
Tomas Takac 5-Feb-15 2:02am    
ok, there is no need for SUM(), just select sal,comm,sal+comm ...

1 solution

i think you are mixedup with the sqlinto.
sql into use to copy record from one table to another table
ref here.
https://msdn.microsoft.com/en-us/library/ms188029.aspx[^]
http://www.w3schools.com/sql/sql_select_into.asp[^]


i think you want like this..
select sal,comm,(sal+comm) as total from emp where comm is not null;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900