First time on this board thanks in advance for any help.
I have a union query to find a median value as follows
SELECT Avg(Q3.R1) AS Median
FROM [
SELECT Max(Q1.R2) AS R1
FROM
(SELECT TOP 50 PERCENT LOS_min_amb_work.los AS R2
FROM LOS_min_amb_work
ORDER BY LOS_min_amb_work.los ASC) AS Q1
UNION ALL
SELECT Min(Q2.R2) AS R1
FROM
(SELECT TOP 50 PERCENT LOS_min_amb_work.los AS R2
FROM los_min_amb_work
ORDER BY LOS_min_amb_work.los DESC) AS Q2
]. AS Q3;
I have another field in the table los_min_amb_work called TSheetTitleDescription that I need to find and display the different medians based on the TSheetTitleDescription. I have tried adding it as an additional union, I have tried just adding the group by statement all with no luck.
Any help would be appreciated.
I have a union query to find a median value as follows
SELECT Avg(Q3.R1) AS Median
FROM [
SELECT Max(Q1.R2) AS R1
FROM
(SELECT TOP 50 PERCENT LOS_min_amb_work.los AS R2
FROM LOS_min_amb_work
ORDER BY LOS_min_amb_work.los ASC) AS Q1
UNION ALL
SELECT Min(Q2.R2) AS R1
FROM
(SELECT TOP 50 PERCENT LOS_min_amb_work.los AS R2
FROM los_min_amb_work
ORDER BY LOS_min_amb_work.los DESC) AS Q2
]. AS Q3;
I have another field in the table los_min_amb_work called TSheetTitleDescription that I need to find and display the different medians based on the TSheetTitleDescription. I have tried adding it as an additional union, I have tried just adding the group by statement all with no luck.
Any help would be appreciated.