我想在gridview
中显示最新插入的记录。如何显示最新插入的记录?
样品DB:
Id Alerts Alert_Date
-- ------ ----------
1 Alert1 5/11/2015 12:12:22 PM
2 Alert2 5/11/2015 12:12:22 PM
3 Alert1 5/12/2015 12:12:22 PM
4 Alert2 5/13/2015 12:12:22 PM
5 Alert2 5/14/2015 12:12:22 PM
6 Alert3 5/14/2015 12:12:22 PM
预期输出:
Alerts Alert_Date
------ ----
Alert1 5/12/2015 12:12:22 PM
Alert2 5/14/2015 12:12:22 PM
Alert3 5/14/2015 12:12:22 PM
SQL:
SELECT DISTINCT Alerts,
(SELECT TOP (1) tbl_Notifications.Alert_Date AS Expr1) AS Expr1
FROM tbl_Notifications
我试过的东西,是上面给出的,但它不起作用。帮助我找到一个合适的解决方案。谢谢。
您正在使用哪个数据库管理系统试试? (TOP是产品特定的SQL。) – jarlh