Viewing 15 posts - 9,301 through 9,315 (of 10,143 total)
Hi Ishaan
Can you please provide some sample data, and an expected result set, as in the link below?
Cheers
ChrisM
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
December 2, 2008 at 11:11 am
Hi 4D
This should start you off.
[font="Courier New"]DROP TABLE #Data
CREATE TABLE #Data ([id] INT, cust_id INT, sales_id CHAR(3), start_date DATETIME, end_date DATETIME)
INSERT INTO #Data ([id], cust_id, sales_id, start_date, end_date)
SELECT 1, 1,...
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
December 2, 2008 at 10:58 am
Grant Fritchey (11/30/2008)
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
December 2, 2008 at 10:21 am
Corobori (12/1/2008)
Chris Morris (12/1/2008)
Hi CoroboriThis will give you your expected results
ChrisM
I think that ROW_NUMBER is a SQL Server 2005 and in my case I am using a SQL Server 2000...
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
December 2, 2008 at 10:01 am
Thanks for the explanation, Gail.
I use 1 just to make it very clear to me and to anyone reading that there's no column access and the column (if any) mentioned...
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
December 2, 2008 at 9:58 am
Chris Morris (12/1/2008)
Madhivanan (12/1/2008)
It must be faster. If not compare the execution paln by applying thesehttp://sqlblogcasts.com/blogs/madhivanan/archive/2008/09/12/return-top-n-rows.aspx
Only the third method would work - and it's exactly the same as the OP'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
December 2, 2008 at 9:44 am
A very similar question was asked and answered here...http://www.sqlservercentral.com/Forums/Topic610366-8-1.aspx#bm610396
Cheers
chrisM
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
December 2, 2008 at 6:45 am
Here's a long shot if you'd like to try it:
SUM(IIF(Fields!totalmoney.Value>105,Fields!totalmoney.Value-105,0))*0.128
Cheers
ChrisM
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
December 2, 2008 at 5:18 am
GilaMonster (12/1/2008)
KPR (12/1/2008)
sorry to reduce it to one sec.That may not be possible. You're doing a lot of work in there.
What are these?
dbo.fn_ProfileLegalVechile(@ProfCode,@Branch)
dbo.fn_ProfileWareHouse(@ProfCode,@WHCode)
dbo.fn_ProfileCurrency(@ProfCode,@CCYCode)
These functions all appear to restrict rows...
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
December 2, 2008 at 4:36 am
Hi KPR
Examining the function which returns a warehouse code, dbo.fn_ProfileWareHouse:
the WHERE clause reads AND B.WHCode = M.WHCode where M is the alias for the table returned by the function.
If @WHCode...
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
December 2, 2008 at 4:07 am
Hi Corobori
This will give you yoyur expected results without randomisation - but I think you should find that part relatively straightforward:
WITH MyCTE AS (SELECT ROW_NUMBER() OVER (PARTITION BY Pr_RealEstateAgent_Id 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
December 1, 2008 at 10:20 am
Gail, did you notice in your testing if there was significant benefit in using
Where not exists (Select 1
instead of Where not exists (Select *
in Query 1? I'm...
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
December 1, 2008 at 9:43 am
Grant Fritchey (12/1/2008)
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
December 1, 2008 at 8:17 am
Not sure if you can get all three updates into one statement, but you can certainly speed things up:
[font="Courier New"]UPDATE TABLE1
SET CHK_DATE = 1
WHERE TRXID IN (SELECT A.TRXID
FROM TABLE1...
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
December 1, 2008 at 8:06 am
Grant Fritchey (12/1/2008)
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
December 1, 2008 at 7:45 am
Viewing 15 posts - 9,301 through 9,315 (of 10,143 total)