我需要先按字母顺序命名我的表格,然后在名称中,日期必须是最近的第一个
这是我尝试过的:
select ME_BORROWER.ABN_BOR_NO, ME_BORROWER.ABN_BOR_NAME, ABN_ACCESS_NO, ABN_LOAN_DATE
from ME_BORROWER LEFT OUTER JOIN ME_LOAN ON
ME_BORROWER.ABN_BOR_NO = ME_LOAN.ABN_BOR_NO
where ABN_TOWN='Leicester' or ABN_TOWN='Hinkley'
GROUP BY ME_BORROWER.ABN_BOR_NAME
ORDER BY ABN_LOAN_DATE asc;
答案 0 :(得分:3)
怎么样:
ORDER BY ABN_BOR_NAME ASC, ABN_LOAN_DATE DESC
答案 1 :(得分:1)
这应该有用......
=IF(A1>A2,A1,A2)
答案 2 :(得分:1)
使用表别名和in
运算符,您的查询会更清晰:
select b.ABN_BOR_NO, b.ABN_BOR_NAME, l.ABN_ACCESS_NO, l.ABN_LOAN_DATE
from P17192142_BORROWER b LEFT OUTER JOIN
P17192142_LOAN l
ON b.ABN_BOR_NO = l.ABN_BOR_NO
where b.ABN_TOWN in ('Leicester', 'Hinkley')
order by b.ABN_BOR_NAME, l.ABN_LOAN_DATE desc;
GROUP BY
似乎没必要。