Arrao4u

…a blog by Rama Rao

Archive for the ‘Queries Part3’ Category

Queries Part3

Posted by arrao4u on December 17, 2009

I have a table with values like:

insert  into table_1 values(1,‘a’,1000,NULL)

insert  into table_1 values(2,‘B’,3000,200)

insert into table_1 values(3,‘C’,2000,300)

insert into table_1 values(4,‘D’,4000,400)

how to add 100 /-to comm and get the total salary=salary+comm+100)?

SELECT ID,NAME,SALARY,ISNULL(COMM,0),(SALARY+ISNULL(COMM,0)+100)AS TOTAL FROM TABLE_1

or

SELECT ID,NAME,SALARY,ISNULL(COMM,0),SUM(SALARY+ISNULL(COMM,0)+100)AS TOTAL FROM TABLE_1 GROUP BY ID,NAME,SALARY,ISNULL(COMM,0)

Posted in Queries Part3 | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.