我要查询查询表 [英] i want a Query for selecting of Table
本文介绍了我要查询查询表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的表格名称是NEWS
以及以下字段:NewsId,NewsTitle,NewsDate
想要查询
通过选择
想要选择此表的3条记录
这3条记录是按日期显示的3条最新消息
我想获取表末3条记录(结束时间3条记录,而不是结束表)
请给我一个查询
解决方案
在这里:
SELECT TOP 3 NewsId,NewsTitle,NewsDate FROM NEWS ORDER BY NewsDate DESC
以下命令对结果进行排序,以便最新的在顶部:
ORDER BY NewsDate DESC
以下内容指示SELECT仅获取前3行:
SELECT TOP 3
您可以使用简单的技巧以升序获取最后3条记录.
SELECT * FROM ( SELECT TOP 3 NewsId,NewsTitle,NewsDate FROM NEWS ORDER BY 新闻日期 DESC ) AS DT 订单 BY DT.NewsDate
hi
a have this table
My table name is NEWS
and this fields: NewsId ,NewsTitle,NewsDate
a want get a query
by select
a want select 3 record of this table
this 3 record is 3 last news by date
i want get 3 record of end of table (3 record of end time,not of end table)
please give me a query
解决方案
Here you go:
SELECT TOP 3 NewsId, NewsTitle, NewsDate FROM NEWS ORDER BY NewsDate DESC
The following orders the results so the newest are at the top:
ORDER BY NewsDate DESC
The following instructs the SELECT to get just the first 3 rows:
SELECT TOP 3
You can use a simple trick to get last 3 records in ascending order.
SELECT * FROM (SELECT TOP 3 NewsId, NewsTitle, NewsDate FROM NEWS ORDER BY NewsDate DESC) AS DT ORDER BY DT.NewsDate
这篇关于我要查询查询表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文