November 10, 2008 at 5:02 am
Hi,
i'm raising the summary tables by using the following query,
INSERT INTO ClientTbl_SummarySalesMonthTY
([RetailerKey]
,[ProductLevel1]
,[AttributeValue]
,[Month]
,[Year]
,[SalesinUnits]
,[GrossSalesValueinDollars]
,[NetSaleValue]
,[StockOnHandinUnits]
,[StockOnHandinDollars]
,[StockOnOrderinUnits]
,[StockOnOrderinDollars]
,[ReplenishmentType]
,[ProductStatus])
select p.Retailerkey
,'Category'
,p.Category
,c.MonthNumRetailYear
,c.RetailYear
,sum(f.[Quantity Sold])
,sum(f.[Gross Sales Value Incl. Tax])
,sum(f.[Net Sales Value Incl. Tax])
,sum(f.[Store Stock Units on Hand])
,sum(f.[Store Stock On Hand Value Excl. Tax])
,sum(f.[Store Stock Units on Order])
,sum(f.[Store Stock On Order Value Excl. Tax])
,p.ReplenishmentType
,P.ProductStatus
from ClientAdmin.dbo.ClientTbl_DimProduct p
inner join ClientAdmin.dbo.ClientTbl_DimCalendar c
on p.retailerkey = c.retailerkey
inner join ClientAdmin.dbo.ClientTbl_FactSalesStock f
on p.productkey =f.productkey and p.retailerkey =f.retailerkey and c.calendarkey=f.calendarkey
group by p.Retailerkey
,'Category'
,p.Category
,c.MonthNumRetailYear
,c.RetailYear
,p.ReplenishmentType
,P.ProductStatus
and getting the following error
Msg 164,
Each GROUP BY expression must contain at least one column that is not an outer reference.
Early help is highly appreciated.
Thanks
Regards
Viji
November 10, 2008 at 5:10 am
Remove 'Category' from your GROUP BY clause
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537November 10, 2008 at 5:36 am
gr8 it works
thanks a lot Mr. Mark
Viji
December 13, 2011 at 9:45 am
Good info about this topic is discussed at:
December 13, 2011 at 10:06 am
sandeep.cs3 (12/13/2011)
Good info about this topic is discussed at:
This thread is from 2008. . .
April 21, 2012 at 12:09 pm
and yet that link was still helpful to me today, in 2012 🙂
April 3, 2014 at 12:28 pm
..and that link is no longer valid, in 2014
July 28, 2016 at 9:30 am
but link is valid in 2016
June 20, 2018 at 3:13 am
Link still alive and helping lost people in 2018 :laugh:
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply