Results 1 to 5 of 5
  1. #1
    jlandis is offline Novice
    Windows XP Access 2000
    Join Date
    Feb 2011
    Posts
    3

    Median Calculations and Group By

    have a median query as follows that I need help grouping the results:

    SELECT Avg([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

    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;

    This query is based on the following query named los_min_amb_work. It has
    built in parameters that work fine in the median query. Allows me to
    calculate a length of stay for a given time period.

    PARAMETERS [Enter Beginning Date] DateTime, [Enter Ending Date] DateTime;
    SELECT Detail.[ED#], Detail.HospitalArrivalTime, TimeValue(
    [HospitalArrivalTime]) AS HATTime, Detail.DispositionTime, IIf((
    [DispositionTime]-[HATTime])<0,(([DispositionTime]-[HATTime])+1)*1440,(
    [DispositionTime]-[HATTime])*1440) AS LOS, Detail.PhysicianExamTime, IIf(
    [DispositionTime]-[PhysicianExamTime]<0,([DispositionTime]-[PhysicianExamTime]
    +1)*1440,([DispositionTime]-[PhysicianExamTime])*1440) AS MDToDT, [Enter
    Beginning Date] AS Beg, [Enter Ending Date] AS [End], DateValue([Detail]!
    [HospitalArrivalTime]) AS HAD, IIf([DispositionTime]-[DispositionOrderTime]<0,
    ([DispositionTime]-[DispositionOrderTime]+1)*1440,([DispositionTime]-
    [DispositionOrderTime])*1440) AS DOTToDT, Detail.EDBedTime, Detail.
    DispositionOrderTime, IIf([DispositionTime]-[PhysicianExamTime]<0,(
    [DispositionTime]-[PhysicianExamTime]+1)*1440,([DispositionTime]-
    [PhysicianExamTime])*1440) AS MDoDOT, Detail.DispositionCode, Detail.Lastname,
    Detail.TSheetTitle, TSheetTitle.TSheetTitleDescription
    FROM Detail INNER JOIN TSheetTitle ON Detail.TSheetTitle = TSheetTitle.
    TSheetTitleNumber
    WHERE (((Detail.HospitalArrivalTime) Between [Enter Beginning Date] And (
    [Enter Ending Date]+1)) AND ((Detail.DispositionCode)=1 Or (Detail.
    DispositionCode)=3 Or (Detail.DispositionCode)=15 Or (Detail.DispositionCode)
    =21 Or (Detail.DispositionCode)=22 Or (Detail.DispositionCode)=23 Or (Detail.
    DispositionCode)=31));

    What I want to do is group the results in the median query by the


    TSheetTitleDescription so the output would be
    TSheetTitleDescription1 Median LOS1
    TSheetTitleDescription2 Median LOS2

    Any thoughts or comments would be appreciated.

  2. #2
    jlandis is offline Novice
    Windows XP Access 2000
    Join Date
    Feb 2011
    Posts
    3

    Anyone?

    Anyone that has viewed this have any ideas?

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    j,

    the reason there's no response to this is probably because it's unreadable. Don't you think?

  4. #4
    jlandis is offline Novice
    Windows XP Access 2000
    Join Date
    Feb 2011
    Posts
    3

    Unreadable?

    Perhaps it is not unreadable rather it is not understood. By most.

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by jlandis View Post
    Perhaps it is not unreadable rather it is not understood. By most.
    I would venture to say that it's not understood because it's not being read. There are very few things about Access that I, and a lot of others here, don't understand, so I would say that's not entirely accurate.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 11-29-2010, 08:16 AM
  2. Median value for multiple columns
    By MIS_Analist in forum Queries
    Replies: 2
    Last Post: 10-08-2010, 11:14 AM
  3. Finding Median in Query
    By randolphoralph in forum Queries
    Replies: 1
    Last Post: 02-19-2010, 11:18 AM
  4. columns for group detail but not group header?
    By Coolpapabell in forum Reports
    Replies: 0
    Last Post: 08-21-2009, 08:53 AM
  5. Median and Mode for a large table
    By brandon in forum Access
    Replies: 0
    Last Post: 05-08-2008, 09:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums