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

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -