Link to home
Start Free TrialLog in
Avatar of running32
running32

asked on

Expression times out when running query

I am trying to get the maximum date for each record.  There are numerous records for each NDC and I need to get the NDC record which has the maximum time stamp for each different NDC how can I do this without the expression timeing out.

thanks
SELECT     r.NPT_PRICEx, r.NDC, r.NPT_DATEC
FROM         RNP2 r INNER JOIN
                          (SELECT     MAX(npt_datec) AS maxbbdc, NDC
                            FROM          rnp2
                            GROUP BY NDC) a ON r.NDC = a.NDC AND r.NPT_DATEC = a.maxbbdc
WHERE     (r.NPT_TYPE = '01')

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of BrandonGalderisi
BrandonGalderisi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
wrong use of words... should have been "and" and not "that covers"


Avatar of running32
running32

ASKER

thank you