常用SQL备忘
保留两位小数
sql server:
1 | select **Convert**(decimal(18,2),2.176544) |
结果:2.18
1 | select **CAST**(2.176544 as decimal(18,2)) |
结果:2.18
1 | select **Round**(2.176544,2) |
结果:2.180000
oracle:
select trunc(1.23856789,2)
round(m,n) 四舍五入
trunc(m,n) 不四舍五入,直接丢弃。
查询重复数据
1 | select * from 表名 a |
递归查询数据
1 | with cte as |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment