同名不再在sql查询中重复

时间:2016-08-05 07:47:08

标签: sql-server

我的表格看起来像这样:

123456(POC)
654656(GSON)-9576767(VID)
55555 
546464(XML)-545454

我想要这样的输出:

ntpdate -bu <ntp server>

1 个答案:

答案 0 :(得分:0)

使用CASE ....

  SELECT 
     CASE WHEN NUMBER_NEW=NUMBER_OLD THEN NUMBER_NEW 
     ELSE NUMBER_NEW+'-'+NUMBER_OLD END AS 'SOMECOLUMN'
    FROM 
    YOURTABLE

输出

123456(POC)
654656(GSON)-9576767(VID)
55555 
546464(XML)-545454