我有以下数据:我想先显示所有具有“到期”状态的最近发票。如何订购此数据。n、 b:我用的是mysql数据库。
lf3rwulv1#
SELECT Date , Invoice , ProductName , Qty , Rate , TotalPrice , PaymentStatus , PaymentType FROM xxxTable ORDER BY PaymentStatus = 'Due' DESC , date DESC
yhqotfr82#
这应按到期、已付和其他顺序排序:
SELECT Date, Invoice, ProductName, Qty, Rate, TotalPrice, PaymentStatus, PaymentType FROM xxxTable ORDER BY CASE WHEN PaymentStatus LIKE "%Due%" then 1 WHEN PaymentStatus LIKE "%Paid%" then 2 ELSE 3 END
pw136qt23#
尝试:
select * from yourtable order by `Payment Status` ,Date desc
3条答案
按热度按时间lf3rwulv1#
yhqotfr82#
这应按到期、已付和其他顺序排序:
pw136qt23#
尝试: