Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all

i m want to add the below query result and have to show in grid after year change

please tell me how to do

SQL
SELECT 15- sum(EL) as el, 1 - sum(CL) as cl, 14 - sum(ML) as ml FROM attendance 
//current value of this query
SQL
SELECT 15- sum(EL) as el, 1 - sum(CL) as cl, 14 - sum(ML) as ml FROM attendance

//new values of this query
Posted
Updated 30-Oct-12 18:50pm
v3
Comments
Sushil Mate 29-Oct-12 3:00am    
What exactly you wanted to achieve here.? please explain in detail.
[no name] 29-Oct-12 3:04am    
What i want is when the year ends the remaining leave values should add up with the fresh leave values..
e.g suppose if at 31st dec leave for a particular person remain
EL-10
CL-1
ML-5
then at 1st jan 2013 it should add up with new values and save in table as total(suppose all leaves are #10)
EL-20
CL-11
ML-15

GROUP BY[^] clause might be what you are looking for.
 
Share this answer
 
Comments
[no name] 29-Oct-12 3:37am    
let me tell u the problem again..
What i want is when the year ends the remaining leave values should add up with the fresh leave values..
e.g suppose if at 31st dec leave for a particular person remain
EL-10
CL-1
ML-5
then at 1st jan 2013 it should add up with new values and save in table as total(suppose all leaves are #10)
EL-20
CL-11
ML-15
damodara naidu betha 30-Oct-12 3:30am    
hi.. what is the table structure? and explain EL,CL,ML.
[no name] 30-Oct-12 3:35am    
EL,CL, ML are the types of leave for each emp.
use substr
int lnlenght=varaible.lenght
nvaraible=convert.todecimal(variable.Substring(3, length);
nvariable = nvaraible +10

newvariable = variable.Substring(0, 3)+nvaraible
 
Share this answer
 
Comments
[no name] 31-Oct-12 1:31am    
I didn't get ur code..can u please explain..
ahmad zrein 31-Oct-12 9:38am    
the query defined do not work.

1. when we use sum or mathematical variable ist sould be done alone, because we must use group by.

SELECT sum(EL) as el, sum(CL) as cl, sum(ML) as ml FROM attendance group by date or id ....

2. What i mean divide the work into two part
part 1 do the sum query
part 2 do subtraction 15, 1, 14 ...
as you want

hope this what i understood

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