[英]How to select LAST record in group by using mysql
以下查詢為您提供每個c_id
具有最新trans_date
的記錄:
select t.*
from tbl_ledger t
where
doc_type = 'B'
and trans_date = (
select max(t1.trans_date)
from tbl_ledger t1
where t1.doc_type = 'B' and t1.c_id = t.c_id
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.