Viewing 15 posts - 2,146 through 2,160 (of 2,171 total)
Should the range be as followed?
01-01-2006..............A.........20
01-01-2006..............B.........20
02-01-2006..............A.........30
02-01-2006..............A.........40
02-01-2006..............B.........10
04-01-2006..............A.........20
04-01-2006..............A.........50
05-01-2006..............A.........40
05-01-2006..............A.........10
Now suppose my daterange is 2 days, so in the above table i need to get the total for :
01-01-2006 - 02-01-2006 (2days) Sum for...
N 56°04'39.16"
E 12°55'05.25"
Here we go again...
DECLARE @FromDate DATETIME,
@ToDate DATETIME,
@DateRange INT,
@SKU VARCHAR(1)
SELECT @FromDate = '2004-01-15',-- This is the starting date in the range
@ToDate...
N 56°04'39.16"
E 12°55'05.25"
The data is not stored as a date range. See example.
"I have a table with the following data (date, value)"
N 56°04'39.16"
E 12°55'05.25"
Or more specific
DECLARE @FromDate DATETIME,
@ToDate DATETIME,
@DateRange INT
SELECT @FromDate = '2004-01-15',-- This is the starting date in the range
@ToDate = '2008-02-20',-- This...
N 56°04'39.16"
E 12°55'05.25"
You mean like this?
DECLARE @FromDate DATETIME,
@ToDate DATETIME,
@DateRange INT
SELECT @FromDate = '2004-01-15',
@ToDate = '2008-02-20',
@DateRange = 20
SELECT MIN(Date)...
N 56°04'39.16"
E 12°55'05.25"
The greatest factor is proper indexes.
I run the two questions against our production server with 90+ million rows.
DISTINCT took 66 seconds.
GROUP BY took 8 seconds.
N 56°04'39.16"
E 12°55'05.25"
Based on the original posting, the query would be someting like
SELECT AggregateGroup, 1 FiscalMonth, Jan Amount FROM MySourceTable
UNION ALL
SELECT AggregateGroup, 2, Feb FROM MySourceTable
UNION ALL
SELECT AggregateGroup, 3, Mar FROM MySourceTable
UNION ALL
SELECT AggregateGroup, 4, Apr FROM MySourceTable
UNION...
N 56°04'39.16"
E 12°55'05.25"
Here is the real query with some optimization techniques...
SELECT SUM(CASE WHEN DT.type = 'r' THEN DT.Items ELSE 0 END) Registrations,
SUM(CASE WHEN DT.type = 'c' THEN DT.Items ELSE 0...
N 56°04'39.16"
E 12°55'05.25"
Heureka! I've found it!
Here is a "one query"-solution...
SELECT DISTINCT CONVERT(SMALLMONEY, x1 + ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) * (x2...
N 56°04'39.16"
E 12°55'05.25"
Viewing 15 posts - 2,146 through 2,160 (of 2,171 total)