Quote:
quote:sum(Code) WHERE RunID=6 + sum(Code) WHERE RunID=6 AND RunID=3,
|
Are u adding RunId=6's sum(Code) twice with that of RunId=3?
Quote:
quote:(Sum(HoursOrDays) WHERE RunID=6 + Sum(HoursOrDays) WHERE RunID=6) AND WHERE Type=1,
(Sum(HoursOrDays) WHERE RunID=6 + Sum(HoursOrDays) WHERE RunID=6) AND WHERE Type=2
|
Do you want twice the sum(Code) here in the above statements??
I'm not sure if this is what you are looking for.
SELECT
(
(SELECT Sum(Code) FROM <TABLENAME> WHERE RunId=6) as SUM_RUNID_6,
(SELECT Sum(Code) FROM <TABLENAME> WHERE RunId in(6,3)) as SUM_RUNID_6AND3,
(SELECT Sum(HoursOrDays) FROM <TABLENAME> WHERE RunId=6 and Type=1) as SUM_RUNID_6_Type_1,
(SELECT Sum(HoursOrDays) FROM <TABLENAME> WHERE RunId=6 and Type=2) as SUM_RUNID_6_Type_2
)
Hope that Helps.
Cheers!
-Vijay G