select min(measurement), part_desc
(case len(measurement)
when 6 then '0000' + part_desc
else '000' + part_desc
end)
from LeachingView
where DateTimeStamp > '2011-01-01' and measurement > 0
group by measurement, part_desc
支持将0000附加到另一个字符的前面,但它不起作用,我想知道为什么以及如何使其正确。
我得到的错误是:
'part_desc'不是公认的内置函数名称。
答案 0 :(得分:4)
根本不需要CASE ......
select
min(measurement),
RIGHT('0000000000' + part_desc, 10) AS part_desc
from...
答案 1 :(得分:1)
select min(measurement),
case len(measurement)
when 6 then '0000' + part_desc
else '000' + part_desc
end as part_desc
from LeachingView
where DateTimeStamp > '2011-01-01'
and measurement > 0
group by case len(measurement)
when 6 then '0000' + part_desc
else '000' + part_desc
end
答案 2 :(得分:1)
我想你想要
Select min(measurment),
(case len(measurement)
when 6 then '0000' + part_desc
else '000' + part_desc
end) AS "part_desc"
From LeachingView
Where...