Link to home
Create AccountLog 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
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of rgb192

ASKER

thanks