Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Variables in Grouped Queries
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Variables in Grouped Queries
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01102741
Message ID:
01102741
Views:
53
Hi all,

If I have a query like this:
declare @date smalldatetime

set @date = dateadd(dd, -1, convert(varchar(10), getdate(), 101))

	insert into DayStoreCat_Committed
			(RetailDate, StoreNo, Category, Committed_Units, Committed_Retail)
	select @date, StoreNo, Category, sum(Committed_Units), sum(Committed_Retail)
		from ItemStCt
		group by StoreNo, Category
Should I add the @date to the group by or is it correct the way I have it.

Oh, and as a side note, if my DayStoreCat_Committed table's PK is (RetailDate, StoreNo, Category) and is clustered, should I add an order by clause to the select (to speed up the insert)?

TIA,
Chad
_________________________________
There are 2 types of people in the world:
    Those who need closure
Next
Reply
Map
View

Click here to load this message in the networking platform