4

我的表中有一个名为“薪水”的列。值存储的另一个表

  • 同样是 50 万 12000..

我要结果

  • 5*10000+12*1000

我创建了一个查询,

SELECT TOP(10) 'INSERT INTO jobs(Budget) VALUES('+
CAST(SUBSTRING(
      CAST(r.Budget AS VARCHAR(50)), 0, PATINDEX('%laks%', r.Budget))*100000 AS VARCHAR(50))
      + ',' +CAST(SUBSTRING(
      CAST(r.Budget AS VARCHAR(50)), PATINDEX('%laks%', r.Budget) + 4
    ,patindex('%Thousands%', r.Budget) - PATINDEX('%laks%', r.Budget) - 4)* 1000  AS VARCHAR(50))+')'
    FROM requirementsdetailsfororganization r

在这里,我可以将单独的值相乘。我不能添加两个值。

当我使用上面的查询时,我的结果是

INSERT INTO jobs(Budget) VALUES(200000,5000)

预期输出:

INSERT INTO jobs(Budget) VALUES(205000)
4

1 回答 1

5
SELECT TOP(10) 'INSERT INTO jobs(Budget) VALUES('+
        CAST(SUBSTRING(CAST(r.Budget AS VARCHAR(50)), 0, PATINDEX('%laks%', r.Budget))*100000
            + SUBSTRING(CAST(r.Budget AS VARCHAR(50)), PATINDEX('%laks%', r.Budget) + 4, 
                                                       patindex('%Thousands%', r.Budget) - PATINDEX('%laks%', r.Budget) - 4)* 1000 AS VARCHAR(50))+')'
    FROM requirementsdetailsfororganization r
于 2013-04-17T11:40:41.020 回答