Viewing 15 posts - 4,741 through 4,755 (of 10,143 total)
faheemahmad14 (4/25/2013)
thanks a lot for your prompt responsebut my requirement is not to use RowNumber or any other builtin function.
ROW_NUMBER is ideal for this - can you explain why you...
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
April 25, 2013 at 7:04 am
SELECT *
FROM #Table1 t1
CROSS APPLY (
SELECT TheDate = CONVERT(DATE,'01/'+LEFT(t1.Period,2)+'/'+RIGHT(t1.Period,4),103)
) x
OUTER APPLY (
SELECT *
FROM #Table2 t2
WHERE t2.Name = t1.Name
AND CONVERT(DATE,'01/'+LEFT(t2.Period,2)+'/'+RIGHT(t2.Period,4),103)
BETWEEN DATEADD(mm,-6,x.TheDate) AND x.TheDate
) y
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
April 25, 2013 at 6:47 am
Thanks Ron.
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
April 25, 2013 at 6:30 am
Abu Dina (4/25/2013)
Was waiting for your solution 😀 Nice!
Thank you! 🙂
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
April 25, 2013 at 6:11 am
Use the MAXRECURSION hint:
SELECT columns
FROM recursivecte
OPTION (MAXRECURSION 0); -- unlimited
In practice you might want to set it to a sensible value then increment, JIC your CTE loops.
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
April 25, 2013 at 5:59 am
-- check the query
SELECT *, UpdateMe = CASE WHEN a.SummaryType <> '0' THEN 'Y' ELSE 'N' END
FROM Table_A a
OUTER APPLY (
SELECT Result = (SUM(ai.Pass)/NULLIF(SUM(ai.VM_Id)*1.0,0)) * 100
FROM Table_A ai
WHERE...
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
April 25, 2013 at 5:51 am
-- Always run a SELECT first to see which rows are affected.
-- This query should return the rows you want to keep
SELECT MemberId, [Event], [Event Date]
FROM (
SELECT MemberId, [Event], [Event...
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
April 25, 2013 at 5:29 am
-- Since there are no matches on col1 between the two tables,
-- surely the starting point of the results table should reflect this?
t.col1 ...
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
April 25, 2013 at 4:44 am
iam777here4u (4/25/2013)
Sorry for the trouble. I hope below code will give better idea....
No worries. I like this better, can we use it? I think folks will find it easier to...
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
April 25, 2013 at 4:40 am
chalam87 (4/25/2013)
hi,before finding sub string you should trim the data otherwise it takes empty data also.
select id,SUBSTRING(Reverse(LTRIM(RTRIM(name))),3,1) from emp
;WITH Sampledata (id, name) AS (
SELECT 1 , 'srinivas ' UNION...
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
April 25, 2013 at 4:31 am
tom.wauters (4/25/2013)
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
April 25, 2013 at 4:19 am
iam777here4u (4/25/2013)
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
April 25, 2013 at 4:08 am
This works too:
WITH CteComplement AS (
SELECT *, CONVERT(numeric(14,2),Value) as Amount
FROM #Test
WHERE PathId IN (30,31)
)
-- Cte to add a flag to dataset, which indicates if the Amount <> 0 (flag =...
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
April 24, 2013 at 9:32 am
Tom, this CTE method does exactly the same thing - it reverses the order in which the two predicates are evaluated. The CTE's aren't evaluated in order, they're more or...
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
April 24, 2013 at 9:22 am
tom.wauters (4/24/2013)
However, I am not a dba-expert, and not that good at analysing query plans.
Can you please explain me a bit...
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
April 24, 2013 at 8:29 am
Viewing 15 posts - 4,741 through 4,755 (of 10,143 total)