Viewing 15 posts - 6,211 through 6,225 (of 10,143 total)
dwain.c (6/22/2012)
If you were right though, does that mean my version is 3125x...
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 22, 2012 at 2:46 am
dwain.c (6/22/2012)
-- Original
(115681 row(s) affected)
SQL Server...
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 22, 2012 at 2:37 am
dwain.c (6/22/2012)
...Sorry, I don't get it. Are you talking my query here or yours?
Yours:
SELECT 1, Tuples = CAST(Prod AS VARCHAR(8000)), value
FROM @t
UNION ALL
SELECT n.n+1, t.Prod + ',' + n.Tuples,...
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 22, 2012 at 2:02 am
dwain.c (6/21/2012)
ChrisM@Work (6/21/2012)
Dwain's code, incidentally, is a flash of genius. It runs 2,500 times faster than mine, because it only works with the rows it has to.
Wow Chris! That's...
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 22, 2012 at 1:45 am
jeffem (6/21/2012)
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 21, 2012 at 8:30 am
jeffem (6/21/2012)
ChrisM@Work (6/21/2012)
David Webb-200187 (6/19/2012)
Let's say you had 50 rows, all with a quantity of 1. The target quantity was 5.
How would you want that brought back? All...
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 21, 2012 at 7:36 am
David Webb-200187 (6/19/2012)
Let's say you had 50 rows, all with a quantity of 1. The target quantity was 5.
How would you want that brought back? All the possible...
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 21, 2012 at 6:13 am
farooq.hbs (6/21/2012)
My Metric Values returning two times Lyk
IsNUll(Sum(Case When Datepart(year,mdate)= 2011 and mt.item_name = 'Hard Savings' then m.value End),0) as HardSavingFY11,
IsNull(Sum(Case When Datepart(year,mdate)= 2012...
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 21, 2012 at 1:41 am
You don't need dynamic SQL for this:
SELECT NewColumn
= CAST(Col1 AS VARCHAR(10)) + ' - '
+ CAST(Col2 AS VARCHAR(10)) + ' - '
+ CAST(Col3 AS VARCHAR(10))...
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 20, 2012 at 6:52 am
Since GENERAL_COMMODITY_CD table has a different cardinality to your result set, having multiple rows per BOOKING_ID, you will need to preaggregate it, either as a CROSS APPLY or as a...
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 20, 2012 at 6:35 am
pwalter83 (6/20/2012)
ChrisM@Work (6/20/2012)
Are you seeing one row per BOOKING_ID in your output?- here's where adequate sample data would have helped 🙂
yeah, I get only one row per BOOKING_ID 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
June 20, 2012 at 5:51 am
Are you seeing one row per BOOKING_ID in your output?
- here's where adequate sample data would have helped 🙂
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 20, 2012 at 5:33 am
pwalter83 (6/20/2012)
---------------------------------
CROSS APPLY (
SELECT
=
STUFF(
(SELECT ', ' + mbc.GENERAL_COMMODITY_CD...
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 20, 2012 at 5:18 am
Thanks Paul: try this...
SELECT
MB.BOOKING_ID,
BOOKING_NUM,
--------------------------------------------------------
a.[BOOKING EQUIPMENT],
--------------------------------------------------------
GENERAL_COMMODITY_CD + ',' AS GENERAL_COMMODITY_CD -- qualify this column with a table alias so others know which table it's from
FROM MG_BOOKING MB
LEFT JOIN (
SELECT
BOOKING_ID,...
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 20, 2012 at 4:42 am
pwalter83 (6/20/2012)
... I have some other tables that are also being used in the query as well. Can that be taken into account as well ?Thanks.
Of course. Can you post...
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 20, 2012 at 2:11 am
Viewing 15 posts - 6,211 through 6,225 (of 10,143 total)