连接同一表中的2列

时间:2019-03-11 22:09:04

标签: sql string oracle concat

在下面的尝试中,我试图连接同一张表中的两列,并在尝试运行它时显示“无效数量的参数”。

 SELECT  Concat(b.OB,',',C.OB) AS LANE 
  ,(
    CASE
            WHEN a.vehicle_class LIKE '601%'
            THEN 'Small'
            WHEN a.vehicle_class LIKE '602%'
            THEN 'Large'
            WHEN a.vehicle_class LIKE '9%'
            THEN 'TOW'
            ELSE 'ERROR'
    END) AS vehicle_size
    , a.*
FROM
    (SELECT *
    FROM    reserved

    ) a
  , location b
  , location c
  , mre_system_parameters SYS
WHERE   b.ob_location_id = a.ob_location_id
AND c.ob_location_id = a.ib_location_id
AND rental_date      > sys.cpd - 20000
AND rental_date     <= sys.cpd
AND a.vehicle_class  LIKE '6%'
AND booking_count    = 1;

COMMIT;

2 个答案:

答案 0 :(得分:3)

Oracle的concat严格接受两个参数,而不是查询中的三个参数。您可以只使用一系列串联运算符(||):

b.OB || ',' || C.OB AS LANE 

答案 1 :(得分:1)

在oracle中,使用||运算符进行连接更为方便。因此,

b.OB || ',' || C.O