I want to show all the values from both tables([JC_ItemDSP10days],[JC_ItemDSP30Days])
when I run this below query, it returns 14210 Rows
select
itemid,sum(qtysold) [NineDaysSold]
from
[HQMatajer].[dbo].[JC_ItemDSP10days]
group by ItemID
when I run this query, it returns 16455 Rows
select
itemid,sum(qtysold) [ThirtyDaysSold]
from
[HQMatajer].[dbo].[JC_ItemDSP30Days]
group by ItemID
Now i want to show all the records from both table, when JC_ItemDSP10days.ItemID=JC_ItemDSP30Days.ItemID,as well as if the records are not in either one of the table also it has to show the result
This is what i tried
select
ItemID =isnull(nineDays.itemid,thirtyDays.ItemID),
CONVERT(DECIMAL(10,2),sum(nineDays.qtysold)) [NineDaysSold],
CONVERT(DECIMAL(10,2),sum(thirtyDays.qtysold)) [ThirtyDaysSold]
from
[JC_ItemDSP10days] nineDays
FULL outer JOIN [HQMatajer].[dbo].[JC_ItemDSP30Days] thirtyDays on nineDays.ItemID=thirtyDays.ItemID
group by nineDays.ItemID,thirtyDays.ItemID
order by ItemID
But the result is wrong
This is the actual value of ItemID=9 From the first two query result