Union Query

Joined
Feb 22, 2011
Messages
1
Reaction score
0
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top