Max of three different tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ju sa
    New Member
    • Feb 2012
    • 1

    Max of three different tables

    I have three tables (joined) with a number of conditions and would also like to have a contition on maximum value for three different tables

    Code:
    Select XX.x, YY.y, ZZ.z, WW.w
    from XX 
    Join YY on XX.x = YY.y
    Join ZZ on YY.ya = ZZ.z And XX.x = ZZ.zb
    Join WW on WW.w = ZZ.zc
    where x = 'my_id'
    --- How can I and do this??? 
    ---- max (XX.x_date, YY.y_date, ZZ.c_date) dat
    and dat < somedate
    and dat > some_otherdate
    Last edited by Rabbit; Feb 24 '12, 04:25 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I have no idea what you're trying to do. A clearer explanation along with sample data and results would help.

    Comment

    • DURGAPRASAD51
      New Member
      • Sep 2013
      • 2

      #3
      I THINK THIS IS WHAT U R TRYING FOR
      Code:
       SELECT * FROM
                 ( Select XX.x, YY.y, ZZ.z, WW.w,GREATEST(XX.x, YY.y, ZZ.z, WW.w) DAT 
      from XX 
      Join YY on XX.x = YY.y
      Join ZZ on YY.ya = ZZ.z And XX.x = ZZ.zb
      Join WW on WW.w = ZZ.zc
      where x = 'my_id') DU WHERE  DU.dat < somedate and DU.dat > some_otherdate

      Comment

      Working...