我有一个如下所示的列
EB.Liter+'L'+EB.CC+'cc'+'-ci'+EB.BlockType+EB.Cylinders+
(
EB.EngBoreIn+'x'+
EB.EngStrokeIn+';'+
EB.EngBoreMetric+'x'+
EB.EngStrokeMetric
) as EngineBase
这个拉数据就像这样
1.3 L 1339 cc L 4 (2.87 x3.15 ;73.0 x80.0 )
但我想尝试像
这样的东西1.3L 1339cc -ci L4 (2.87x3.15; 73.0x80.0)
如果可能,请有人建议
我尝试过这样的事情。
LTRIM(RTRIM(EB.Liter))+'L'+LTRIM(RTRIM(EB.CC))+'cc'+'-
ci'+LTRIM(RTRIM(EB.BlockType))+LTRIM(RTRIM(EB.Cylinders))+
+ (
LTRIM(RTRIM(EB.EngBoreIn))+'x'+
LTRIM(RTRIM(EB.EngStrokeIn))+';'+
LTRIM(RTRIM(EB.EngBoreMetric))+'x'+
LTRIM(RTRIM(EB.EngStrokeMetric))
) as EBase
得到我的结果如下 1.3L1339cc-ciL42.87x3.15; 73.0x80.0
但正确的输出为 1.3L 1339cc -ciL4(2.87x3.15; 73.0x80.0)
答案 0 :(得分:1)
像这样修改
LTRIM(RTRIM(EB.Liter))+'L '+LTRIM(RTRIM(EB.CC))+'cc '+'-ci'+LTRIM(RTRIM(EB.BlockType))+LTRIM(RTRIM(EB.Cylinders))+
+ '('+
LTRIM(RTRIM(EB.EngBoreIn))+'x'+
LTRIM(RTRIM(EB.EngStrokeIn))+'; '+
LTRIM(RTRIM(EB.EngBoreMetric))+'x'+
LTRIM(RTRIM(EB.EngStrokeMetric))
+')' as EBase
答案 1 :(得分:0)
您可以使用trim功能删除前导和尾随空格。您的查询将如下所示:
TRIM(EB.Liter) + 'L'+TRIM(EB.CC)+'cc'+'-ci'+TRIM(EB.BlockType)+TRIM(EB.Cylinders)+
(
TRIM(EB.EngBoreIn)+'x'+
TRIM(EB.EngStrokeIn)+';'+
TRIM(EB.EngBoreMetric)+'x'+
TRIM(EB.EngStrokeMetric)
) as EngineBase