www.zbgf.net > sql取排序后的第一行

sql取排序后的第一行

SELECT top 1 a.TRANS_DATE FROM a WHERE rownum = 1 ORDER BY to_date(to_char(a.TRANS_DATE,'yyyy/MM/dd'),'yyyy/MM/dd') DESC ;

比较一般性的查询方法, 用row_number() over(partition by ... order by ...)先给记录按na列的值分组排序(按no降序),然后取出编号值为3~6的记录即可. select s.*from ( select d.no, d.na, d.nb, row_number() over(partition by na order by n...

--SQL Server 2000 select top (5) * from ( select top 15 * from 表 order by 排序列 desc ) as a order by 排序列 desc --SQL Server 2005,2008,2008R2,2012通用方法 select * from ( select *,row_number() over (order by 排序列 desc) as ...

这个不会有什么风险的,请参考下列SQL语句 select top 3 * from t1 order by col1 asc;

select top 1 * from 表名 where (后加你查询结果的限制条件)

假设排序的字段名字为field1降序, table name: tab SELECT field1, field2, field3... fieldn FROM (SELECT field1, field2, field3...fieldn, ROW_NUMBER() OVER(ORDER BY field1 DESC) AS RK ) FROM tab ) t WHERE rk = 1 00904是说列名不正确...

题主可以参考下列例句: select top 10 * from sales order by date_sell dese,price asc;

没有看到你的数据库conn连接啊: @$conn = mysql_connect("yourHost","yourUserID","yourPassword"); $sql=mysql_query("select top 3 title from art_title join art_neirong on art_title.no=art_neirong.no order by last_update DESC;",$conn...

SQL TOP 子句 TOP 子句用于规定要返回的记录的数目。 对于拥有数千条记录的大型表来说,TOP 子句是非常有用的。 注释:并非所有的数据库系统都支持 TOP 子句。 SQL Server 的语法: SELECT TOP number|percent column_name(s) FROM table_name M...

SELECT TOP 10 * FROM 表名 ORDER BY 排序字段

网站地图

All rights reserved Powered by www.zbgf.net

copyright ©right 2010-2021。
www.zbgf.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com