电脑技术学习

查出最早登录的数据和最晚登录的数据番号

dn001

问:如何才能查出一天中最早登录的数据番号和最晚登录的数据番号和时间?

解答:具体示例如下:

SELECT * FROM (

SELECT A_RENBAN,TOUROKU_DT FROM A WHERE TOUROKU_DT IN (SELECT MAX(TOUROKU_DT) FROM A GROUP BY TO_DATE(TOUROKU_DT))

UNION

SELECT A_RENBAN,TOUROKU_DT FROM A WHERE TOUROKU_DT IN (SELECT MIN(TOUROKU_DT) FROM A GROUP BY TO_DATE(TOUROKU_DT))

) ORDER BY A_RENBAN DESC;