Hi there,

I have three Select Queries each of which returns two rows. I associate this in a single Query as follows...

SELECT t1.Today, t2.Yest,t3.Earlier FROM
(SELECT Sum(EstimateMins) as Today from ProductionTbl
WHERE CONVERT(varchar(10),requiredBy,103) = CONVERT(varchar(10),GETDATE(), 103)
union
Select ISNULL(Sum(EstimateMins),0) as Today_Comp from ProductionTbl EP
LEFT JOIN JobsTbl SJ ON SJ.JOB_ID=EP.ROWID
WHERE (CONVERT(varchar(10),requiredBy,103) = CONVERT(varchar(10),GETDATE(), 103))
AND (EP.retouchstatus='Completed' OR SJ.Job_Status='Completed') )as t1 ,

(SELECT Sum(EstimateMins) as Yest from ProductionTbl
where CONVERT(varchar(10),requiredBy,103) = CONVERT(varchar(10), DATEADD(day, -1, GETDATE()), 103)
union
Select ISNULL( Sum(EstimateMins) ,0)as Yest_Comp from ProductionTbl EP
inner JOIN JobsTbl SJ ON SJ.JOB_ID=EP.ROWID
WHERE ( CONVERT(varchar(10),requiredBy,103) = CONVERT(varchar(10), DATEADD(day, -1, GETDATE()), 103))
AND (EP.retouchstatus='Completed' OR SJ.Job_Status='Completed')) as t2,

(SELECT Sum(EstimateMins) as Earlier from ProductionTbl
where CONVERT(varchar(10),requiredBy,103) < CONVERT(varchar(10), DATEADD(day, -1, GETDATE()), 103)
union
Select ISNULL( Sum(EstimateMins) ,0)as Yest_Comp from ProductionTbl EP
inner JOIN JobsTbl SJ ON SJ.JOB_ID=EP.ROWID
WHERE CONVERT(varchar(10),requiredBy,103) < CONVERT(varchar(10), DATEADD(day, -1, GETDATE()), 103)
AND (EP.retouchstatus='Completed' OR SJ.Job_Status='Completed')
)as t3
group by t1.Today, t2.Yest,t3.Earlier
order by t1.Today desc

When running this It returns 6 rows(4 rows return null values) . Iwant to get only 2 rows()

PLease help me to solve this.. Other way of wrting query for this output is also welcomed..