select statement help
Hi to all,
I have this select statement that works fine only when I have my column name MasterSKU together but I need it separate Master SKU because my intranet .asp calling this store procedure has a space in column name... the reason why I don't want to change it to together is because I have lots of other .asp pages that have the space...
select * from(
select '0' as SKU,
MasterSKU as 'Master SKU',
DeptNo 'Category',
VendorStyle 'Vendor Style',
Description, Cost, RetailPrice 'Retail Price',
sum(Quantity) 'QTY Sold',
sum(ExtendedSellingPrice)'Total Sales',
sum(ExtendedSellingPrice)/Abs(sum(Quantity)) 'Average Sale'
From GroupedTransactionDetails, DGSKU
Where SKUUPC=SKU
and SKUUPC>9999
and (SKUUPC/1000=999)
and TransactionDetailDate >= '01/09/05'
and TransactionDetailDate <= '01/14/05'
Group By MasterSKU,DeptNo,VendorStyle,Description,Cost, RetailPrice
Having sum(Quantity) <> 0
) as rino
join
(Select Sum(UnitsOnHand) as 'On Hand',DGSKU.MasterSKU 'Master SKU' from SKUDetails
Join DGSKU on DGSKU.SKU=SKUDetails.SKU
Group by DGSKU.MasterSKU) as mary
On mary.Master SKU=rino.Master SKU
The error I'm getting is on the last line...
Is there a way I can write it with a space to make it work...
Thanking you in advance
Rino
|