我有这个查询,但它不能正常工作,
with c as (select
month(bookingdate) as duration,
count(*) as totalbookings
from
entbookings
group by month(bookingdate)
),
d as (SELECT
duration,
sum(totalitems)
FROM
[DrySoftBranch].[dbo].[mnthItemWiseTotalQty] ('1') AS BkdQty
group by duration
)
select
c.duration,
c.totalbookings,
d.bkdqty
from
c
inner join d
on c.duration = d.duration
当我运行这个时,我得到
消息 8155,级别 16,状态 2,第 1 行
没有为“d”的第 2 列指定列。
谁能告诉我我做错了什么?
另外,当我运行这个时,
with c as (select
month(bookingdate) as duration,
count(*) as totalbookings
from
entbookings
group by month(bookingdate)
),
d as (select
month(clothdeliverydate),
SUM(CONVERT(INT, deliveredqty))
FROM
barcodetable
where
month(clothdeliverydate) is not null
group by month(clothdeliverydate)
)
select
c.duration,
c.totalbookings,
d.bkdqty
from
c
inner join d
on c.duration = d.duration
我明白了
消息 8155,级别 16,状态 2,第 1 行
没有为“d”的第 1 列指定列。
消息 8155,级别 16,状态 2,第 1 行
没有为“d”的第 2 列指定列。