Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

adding latest datetime to existing query

I want to add latest orderitems.dateadded (datetime) to each row of query



select i.productid,COUNT(*) cnt
  from orderitems i
  left join products p on p.productid=i.productid
 group by i.productid
 order by cnt
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image



select i.productid, MAX(i.dateadded), COUNT(*) cnt
  from orderitems i
  left join products p on p.productid=i.productid
 group by i.productid
 order by cnt
ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
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
Avatar of rgb192

ASKER

thanks