質問

I have some queries like the following:

SELECT StoresCasesByMonth.Category, StoresCasesByMonth.Chain, Sum(StoresCasesByMonth.CasesShipped) AS CasesShipped
FROM StoresCasesByMonth, QueryDates
WHERE StoresCasesByMonth.Month Between QueryDates.StartDate And QueryDates.EndDate;

QueryDates is used as a lookup table that specifies a date range, and is one row of two columns:

StartDate   EndDate
1/1/2013    1/12/2013

The reason I use this table is I need to link to some of these queries from Excel, and Excel cannot do this when the queries use parameters, which would otherwise be my first option for specifying a date range.

So my question(s) is(/are):

a) is there a way to rewrite the SQL so it doesn't use a 'comma' join, as I know this (rightly) looks like a fudge,

and b) is there another way of using some kind of variable value across lots of queries that doesn't involve parameters, as I know this (rightly) looks like a fudge.

役に立ちましたか?

解決

a) No, and yes it does.

b) No, and yes it does.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top