1.根据出生日期计算当前已满周岁

DECLARE @birth datetime
SET @birth='1990-01-01'
SELECT (cast(convert(char( 8 ),GETDATE(),112) as int) - cast(convert(char(8),@birth,112) as int))/10000

 

2.COUNT(expression) just returns the total number of rows in which that expression is not null.

COUNT函数返回值不为null的行数。

ID FullName
1 NULL
2 NULL
SELECT COUNT(1) FROM t1 -- Returns 2
SELECT COUNT(FullName) FROM t1 -- Returns 0
COUNT(expression) just returns the total number of rows in which that expression is not null. - See more at: http://www.sqlteam.com/article/how-to-use-group-by-in-sql-server#sthash.b6O058Mg.dpuf

 (持续更新中)

相关文章:

  • 2022-12-23
  • 2022-01-19
  • 2022-02-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
猜你喜欢
  • 2022-02-06
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2021-05-21
相关资源
相似解决方案