Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Variables in Grouped Queries
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Variables in Grouped Queries
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01102741
Message ID:
01102741
Vues:
55
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform