日期:2014-05-18 浏览次数:20734 次
SELECT FLOOR([quantity]) FROM [tb]
------解决方案--------------------
select distinct 列名 from 表名
select count(*) from 表名
看看记录数是否相等
------解决方案--------------------
select cast([quantity] as int) from 表名
------解决方案--------------------
--> 测试数据:[tb] IF OBJECT_ID('[tb]') IS NOT NULL DROP TABLE [tb] GO CREATE TABLE [tb]([quantity] NUMERIC(9,3)) INSERT [tb] SELECT 0.8 UNION ALL SELECT 1.8 UNION ALL SELECT 30.259 UNION ALL SELECT 0.003 UNION ALL SELECT 122323 --------------开始查询-------------------------- SELECT b.[quantity],CASE WHEN b.cnt>1 THEN 'F' ELSE 'T' END FROM [tb] a LEFT JOIN( SELECT FLOOR([quantity]) AS [quantity],COUNT(*) AS cnt FROM [tb] GROUP BY FLOOR([quantity]) ) b ON FLOOR(a.[quantity]) =b.[quantity] ----------------结果---------------------------- /* quantity --------------------------------------- ---- 0 F 1 T 30 T 0 F 122323 T (5 行受影响) */
------解决方案--------------------
SELECT CASE COUNT(1) WHEN 1 THEN 'TRUE' ELSE 'FALSE' END AS count FROM tba GROUP BY TNT