iT邦幫忙

0

如何一起把(用人費)跟(折舊攤銷)同時INSERT INTO再加上SELECT

  • 分享至 

  • xImage

https://ithelp.ithome.com.tw/upload/images/20200504/20126770V1pMqvkPu4.png
請問各位大大幫我解決一下我的困惑!
把圖裡折舊攤銷的值(2615.427256)同時輸入到第一行2848.8842562的旁邊
下面是我查詢的程式碼,請各位大大幫幫我了!
select sum(AmtOrg)/3/1000 as 用人費
from PRODDB2.[GGL].[dbo].[VchrDMonthSum]
where orgCompany='JU' AND (Bid=100 or Bid = 110 or Bid = 120 or Bid = 130
or Bid = 140 or Bid = 150 or Bid = 160 or Bid = 170)
and year=2020
and month<=3

select sum(AmtOrg)/3/1000 as 折舊攤銷費用
FROM PRODDB2.[GGL].[dbo].[VchrDMonthSum]
where orgCompany='JU' AND (Bid=620 or Bid = 640 or Bid = 900 or Bid = 910
or Bid = 920 or Bid = 930 or Bid = 940 or Bid = 950)
and year=2020
and month<=3

player iT邦大師 1 級 ‧ 2020-04-30 18:03:53 檢舉
誰叫你只貼圖的?
這樣別人看到就不想幫了
原本只要剪貼一下
幫你重組一下SQL命令就可以了
而且Fee005_1Cost的Table應該不會只有2個欄位吧
圖片跳過,下一位!!!!!
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
rogeryao
iT邦超人 7 級 ‧ 2020-04-30 20:44:35
CREATE TABLE VchrDMonSum(year int,month int,orgCompany nvarchar(10),Bid int,AmtOrg int);
CREATE TABLE Fee0051Cost(FinalOrd float);
insert Fee0051Cost(FinalOrd)
select sum(AmtOrg)/3/1000.0
from VchrDMonSum
where orgCompany='JU'
and year=2020
and month<=3
and (Bid=100 or Bid=110 or Bid=120 or Bid=130)
--
union all
select sum(AmtOrg)/3/1000.0
from VchrDMonSum
where orgCompany='JU'
and year=2020
and month<=3
and (Bid=620 or Bid=640 or Bid=900 or Bid=910 or Bid=920)

Demo

我要發表回答

立即登入回答