表1
Value (Always 3 Digit)
100x200x300
200x400x500
...
...
我想从值列
创建3列预期产出
val1 val2 val3
100 200 300
200 400 500
...
...
需要查询帮助
答案 0 :(得分:3)
这会利用PARSENAME而不是SUBSTRING。
SELECT
PARSENAME(Value2, 3) AS val1,
PARSENAME(Value2, 2) AS val2,
PARSENAME(Value2, 1) AS val3
FROM
(
SELECT
REPLACE(Value, 'x', '.') AS Value2
FROM
MyTable
) T;
此代码
答案 1 :(得分:2)
SELECT SUBSTRING([VALUE],1,3) AS val1,
SUBSTRING([VALUE],5,3) AS val2,
SUBSTRING([VALUE],9,3) AS val3
FROM TABLE1