我有这个查询,但它没有按照应该的方式工作。
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
运行此代码时,我得到以下错误:
Msg 8155,Level 16,State 2,Line 1
没有为'd'的第二列指定列。
请问我做错了什么?
另外,当我运行这个时,
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未指定列。