sql - subtract values in different columns and different rows -
i have 1 table following values:
job name start_dt end_dt gggggg 4/5/2013 5/5/2013 iiiii 6/5/13 7/8/13
i want subract start_dt
of gggggg
end_dt
of iiiii
.
i using query:
select a.job_nm,(b.end_dt-a.start_dt) difference job a,b a.job_nm='ggggg' , b.job_nm='iiiii'.
this giving me no output.
if sql server can use datediff()
:
select a.job_nm, datediff(day, a.start_dt, b.end_dt) [difference] job a,b a.job_nm='ggggg' , b.job_nm='iiiii'
Comments
Post a Comment