Wrox Programmer Forums
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 16th, 2007, 10:50 AM
Friend of Wrox
Join Date: Oct 2006
Posts: 112
Thanks: 12
Thanked 0 Times in 0 Posts
Default 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
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
(Select Sum(UnitsOnHand) as 'On Hand',DGSKU.MasterSKU 'Master SKU' from SKUDetails
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


Old January 16th, 2007, 10:57 AM
Authorized User
Join Date: Dec 2006
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts

You can wrap the column name in [].
(i.e. On mary.[Master SKU] = rino.[Master SKU]

Adam Gossage
Lake Wylie, SC, USA
Old January 16th, 2007, 11:35 AM
Friend of Wrox
Join Date: Oct 2006
Posts: 112
Thanks: 12
Thanked 0 Times in 0 Posts

It works...



Similar Threads
Thread Thread Starter Forum Replies Last Post
select statement ??? RinoDM SQL Server 2000 7 June 19th, 2008 08:40 AM
select Statement gregalb SQL Server 2000 3 January 15th, 2008 12:00 AM
select statement help... RinoDM SQL Server 2000 13 January 10th, 2008 08:34 PM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Select Statement jmss66 Oracle 1 May 27th, 2004 02:31 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.