爱玺玺

爱玺玺的生活日记本。wx:lb87626

mysql group分组取出分组第一条数据


mysql> select plan_id, SUBSTRING_INDEX(group_concat(plan_day_budget order by id desc),',',1)  from new_syinfo group by plan_id;

+---------+-----------------------------------------------------------------------+

| plan_id | SUBSTRING_INDEX(group_concat(plan_day_budget order by id desc),',',1) |

+---------+-----------------------------------------------------------------------+

|  195299 | 500.00                                                                |

|  203484 | 1000.00                                                               |

|  209631 | 500.00                                                                |

|  210399 | 500.00                                                                |

|  212804 | 2000.00                                                               |

|  213417 | 1600.00                                                               |

|  216290 | 500.00                                                                |

|  221808 | 1800.00                                                               |

|  232613 | 2000.00                                                               |

|  243030 | 500.00                                                                |

|  243908 | 800.00                                                                |

|  245738 | 500.00                                                                |

+---------+-----------------------------------------------------------------------+

12 rows in set


发表评论:

Powered By Z-BlogPHP 1.4 Deeplue Build 150101

Copyright Your WebSite.Some Rights Reserved.

蜀ICP备11021721号-5