SELECT CONVERT(varchar(100), GETDATE(), 23) AS 日期
结果:2017-01-05
select ISNULL(price,'0.0') FROM table
将表中为null的值变成0.0
select * from [DBData].[dbo].[T_Student] where [Name]='LILEI'
等效于:
select * from [DBData].[dbo].[T_Student] where [Name]='lilei'
select [Name],MAX(Score),AVG(Score) FROM [DBData].[dbo].[T_Student] group by Name order by Name
注意:聚合函数忽略空值数据
SQL中开窗函数OVER():
作用:
1、为每条数据显示聚合信息(聚合函数);
2、为每条数据提供分组的聚合函数结果(聚合函数() over(PARTITION BY 字段) as 别名);
3、与排名函数一起使用 (ROW_NUMBER() over(order by 字段) as 别名)