Home  >  Q&A  >  body text

Using the from method to find the latest products under each column, why are the results incorrect?

Use the from method to find the latest products under each column. Why are the results incorrect?

select goods_id,cat_id,goods_name from (select * from goods where 1 order by cat_id asc,goods_id desc )as tep group by cat_id;

P粉441358353P粉441358353802 days ago694

reply all(2)I'll reply

  • 雪漫雨悠

    雪漫雨悠2022-08-09 15:47:37

    Grouping-》Sort-》Get the latest

    reply
    0
  • P粉441358353

    Hello, I would like to ask why what I wrote is the same as what the teacher said, but the from clause in the middle does not work. The latest goods_id obtained is still the first value of each column before sorting.

    P粉441358353 · 2022-08-09 20:38:05
  • Cancelreply