Viewing 15 posts - 6,841 through 6,855 (of 10,143 total)
;WITH Calculator1 AS (
SELECT Historyid, ID, LetterNo, letter,
rn1 = ROW_NUMBER() OVER(ORDER BY Historyid),
rn2 = ROW_NUMBER() OVER(PARTITION BY Letter ORDER BY Historyid)
FROM #Test),
Calculator2 AS (
SELECT Historyid, ID, LetterNo,...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 12, 2011 at 4:41 am
Facebook is awesome for retaining a link with distant relatives. I have cousins in Canada and Hong Kong (and family scattered all around the UK) and FB lets me keep...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 12, 2011 at 2:59 am
Here's another APPLY solution:
DROP TABLE #Strings
CREATE TABLE #Strings (Longstring VARCHAR(150))
INSERT INTO #Strings (Longstring) values ('SABRE a CIRCUIT BREAKER MOTORISATION SCHEMATIC DIAGRAM, FOR USE WITH MICOM & A MULTI VOLTAGE SHUNT...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 11, 2011 at 9:45 am
Daniel Bowlin (7/11/2011)
falling behind
It's all going South sooner or later.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 11, 2011 at 8:03 am
John Mitchell-245523 (7/7/2011)
... the value will be updated with all the values, leaving the one that was done last as the value that persists...
From BOL UPDATE section: "...This is because...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 7, 2011 at 7:05 am
SQLkiwi (7/7/2011)
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 7, 2011 at 6:39 am
SQLkiwi (7/7/2011)
There's no need for a join at all - a point I realised after editing the TOP trick into your code. I have updated the code and...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 7, 2011 at 5:50 am
The new version runs faster but not by much.
So the optimizer converts what looks like a triangular join (the entire CROSS APPLY part) into a TOP query?
Interestingly, you can...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 7, 2011 at 5:36 am
Nice one, Paul. The triangular join put me off writing and testing it, but in practice the performance is stunningly good - half a million rows return in 12s on...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 7, 2011 at 4:47 am
Craig Farrell (7/6/2011)
Jeff Moden (7/6/2011)
Chris,Do you know of a way to use the rCTE to do a running total without the ID's being perfectly sequential?
There's a way using Cross Apply...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 7, 2011 at 2:04 am
tommey152 (7/6/2011)
Hi ,.....
Is there any SQL statement that can do this easily? What's the best way to accomplish this?
Easiest is the recursive CTE:
DROP TABLE #SourceData
CREATE TABLE #SourceData (id INT...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 6, 2011 at 6:57 am
-- simplest
SELECT *
FROM t
WHERE YEAR(CASE
WHEN t.[type] = 'import' THEN t.arrdate
WHEN t.[type] = 'export' THEN t.depdate
ELSE NULL END) = YEAR(@deparr)
-- possibly faster
SELECT *
FROM t...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 1, 2011 at 9:07 am
Today's Random World: "Dragon's Egg".
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 1, 2011 at 8:10 am
SQLkiwi (6/30/2011)
ChrisM@Work (6/30/2011)
...code...
Hi Chris,
You might be interested in a slight tweak to that code. Take a look at the query plans for these:
...
Notice the special distinct sort in the...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 1, 2011 at 2:05 am
eseosaoregie (6/30/2011)
Every RU and BU combo is related to more than 1 ENT....
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 30, 2011 at 6:51 am
Viewing 15 posts - 6,841 through 6,855 (of 10,143 total)