Viewing 15 posts - 2,746 through 2,760 (of 3,957 total)
You don't really need a temp table. All you need to do is modify the first CTE in Chris's approach (add WHERE):
;WITH
MyTrans AS (
...
September 20, 2012 at 11:59 pm
Sounds like an interesting problem.
But you'll need to provide some DDL (CREATE TABLE statements), sample data and a clear picture of the expected results.
That will assure you get a tested...
September 20, 2012 at 11:46 pm
I'm no expert, but can I still reply?
What you need is a crosstab query, which is pretty straightforward given a known number of tariffs and the fact that you even...
September 20, 2012 at 11:27 pm
avssrk (9/20/2012)
In Table A , Same set of Classes Cannot be Grouped
In Table B...
September 20, 2012 at 11:08 pm
Chris - Trying out your new approaches in the below test harness (800K rows):
CREATE TABLE #Customer
( CustKey INT
,SSN ...
September 20, 2012 at 11:04 pm
Actually the OP said he wants to look back 1 year, hence:
DATEDIFF(dd,MIN(TransDate),MAX(TransDate))
So maybe your Tally table takes the performance hit for no reason when you can just use the...
September 20, 2012 at 6:25 pm
Eugene Elutin (9/20/2012)
aaron.reese (9/20/2012)
I do have to agree with the byte-bloat issue.
Can anyone beat this? its from the NHS clinical data set upload for patient details
<personGenderCodeCurrent>M</personGenderCodeCurrent>
There is nothing wrong with...
September 20, 2012 at 8:40 am
You're welcome.
I know the author well. He's not that skilled but once in awhile gets inspired.:-D
September 20, 2012 at 6:08 am
aaron.reese (9/20/2012)
I do have to agree with the byte-bloat issue.
Can anyone beat this? its from the NHS clinical data set upload for patient details
<personGenderCodeCurrent>M</personGenderCodeCurrent>
They must be doing those special sex-change...
September 20, 2012 at 6:00 am
dwain.c (9/20/2012)
ChrisM@Work (9/20/2012)
dwain.c (9/20/2012)
...I knew someone would come along that knew what they were doing and best me. 😀
Haha! I had no idea that this query would be any faster...
September 20, 2012 at 5:24 am
ChrisM@Work (9/20/2012)
dwain.c (9/20/2012)
...I knew someone would come along that knew what they were doing and best me. 😀
Haha! I had no idea that this query would be any faster when...
September 20, 2012 at 4:50 am
David Moutray (9/20/2012)
Here are the IO/timing results:
----------------- Dwain
Table 'Worktable'. Scan count 368, logical reads 101966, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob...
September 20, 2012 at 4:40 am
ChrisM@Work (9/20/2012)
SELECT
t.TransID,
c.SSN,
t.TransDate,
t.Amount
FROM #Customer c
INNER JOIN #TransDtl t
ON t.CustKey = c.CustKey
CROSS APPLY (
SELECT Amount = SUM(ti.Amount)
FROM #TransDtl ti
WHERE t.CustKey = c.CustKey
AND ti.TransDate BETWEEN t.TransDate-1...
September 20, 2012 at 4:37 am
Viewing 15 posts - 2,746 through 2,760 (of 3,957 total)