Viewing 15 posts - 3,496 through 3,510 (of 10,143 total)
tfendt (3/24/2014)
The problem with this query is it returns data for dealer id 3. The business rule I was given was that they only want to see the top 80%....
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
March 24, 2014 at 8:17 am
SELECT
c.claim_id,
c.claim_created,
x.[order],
x.[order_created]
FROM #claim c
CROSS APPLY (
SELECT
[order] = MIN(order_id),
[order_created] = MIN(created_dtm)
FROM dbo.[order] o
WHERE o.claim_id = c.claim_id
) x
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
March 24, 2014 at 8:04 am
Eirikur Eiriksson (3/24/2014)
ChrisM@Work (3/24/2014)
DECLARE @pString VARCHAR(8000), @pDelimiter CHAR(1);
SELECT @pString = 'The,quick,brown,fox', @pDelimiter = ',';
WITH E1(N) AS (
...
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
March 24, 2014 at 5:40 am
The article isn't always easy to follow and might be helped by this:
DECLARE @pString VARCHAR(8000), @pDelimiter CHAR(1);
SELECT @pString = 'The,quick,brown,fox', @pDelimiter = ',';
WITH E1(N) AS (
...
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
March 24, 2014 at 4:27 am
micalo (3/23/2014)
Thanks for trying but didn't work unfortunately. I had another crack at it but in the end decided the that its really in the best interest of 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
March 24, 2014 at 3:07 am
Gotcha - think you're looking for this:
;WITH
Preagg AS (
SELECT DealerID, Tire, RepairsOfThisTyre,
RepairsForThisDealer = SUM(RepairsOfThisTyre) OVER(PARTITION BY DealerID)
FROM (
SELECT DealerID, Tire,
RepairsOfThisTyre = COUNT(*)
FROM #Table1 d
INNER JOIN #Table2 r...
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
March 21, 2014 at 10:46 am
dana 6761 (3/21/2014)
I have a query in a stored procedure that I want to put into a view to improve response time...
It won't improve response time.
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
March 21, 2014 at 9:39 am
What do you mean by "Total # of tires for the size"?
Here's your data set up in a consumable format:
DROP TABLE #Table1
CREATE TABLE #Table1 (DealerID INT, RepairID INT)
INSERT INTO...
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
March 21, 2014 at 9:31 am
ramana3327 (3/21/2014)
Hi,I am working on tuning of sp. They wrote several left outer join. Is there any option to avoid them. Any suggestions please
Left joins are a logic decision, too...
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
March 21, 2014 at 8:41 am
Then you might want to look at this next:
where convert(varchar,DESPATCH_NOTE_DATE,111) >= @date
This expression means that any index on DESPATCH_NOTE_DATE can't help. Rather than converting DESPATCH_NOTE_DATE to match @date, do...
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
March 21, 2014 at 8:16 am
It's the estimated plan - the actual plan is more useful.
The estimated plan you've posted carries this index recommendation:
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[DESPATCH_REPORTS] ([SourceWarehouse])
INCLUDE ([CUSTOMER],[SALES_ORDER],[DESPATCH_NOTE_DATE],[TargetWarehouse])
It would...
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
March 21, 2014 at 6:42 am
Yes, thanks.
(
select top 1 (sm2.SalesOrder)
from SorDetail sd2
left join SorMaster sm2
on sm2.SalesOrder = sd2.SalesOrder
where sd2.LoadNumber = sd.LoadNumber
and sm2.Customer = ar.Customer
)
Top of what exactly, it's missing ORDER...
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
March 21, 2014 at 6:31 am
Can you please post the actual execution plan (of the query including the subquery) as a .sqlplan file attachment? Cheers.
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
March 21, 2014 at 6:12 am
micalo (3/21/2014)
People can put whatever they want in there unfortunately. There no really way without going through all the data that i can think of. I personally think its...
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
March 21, 2014 at 5:49 am
It's an old thread, Wesley - so it's quite likely that none of the respondents will reply. Are you experiencing a similar issue? If so, your best option might be...
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
March 21, 2014 at 4:43 am
Viewing 15 posts - 3,496 through 3,510 (of 10,143 total)