Viewing 15 posts - 2,506 through 2,520 (of 10,143 total)
Like this?
SELECT
t.*,
x.RollingSum
FROM #team t
OUTER APPLY (
SELECT RollingSum = SUM(expense_amt)
FROM #team ti
WHERE ti.team_id = t.team_id
AND ti.date <= t.date
AND ti.date >= DATEADD(month,-3,t.date)
) x
WHERE t.date >= DATEADD(year, -1, GETDATE())
ORDER BY...
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
May 18, 2015 at 4:47 am
Michael L John (5/15/2015)
+ 100.I did not have enough caffeine today! As soon as I saw your post I hit myself on the head!
There won't be a person 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
May 15, 2015 at 8:41 am
maheendra.puttareddy (5/15/2015)
SET Year= casewhen MSDate > '2011/06/30' and MSDate < '2012/07/01' THEN '2012'
when MSDate > '2012/06/30' and MSDate < '2013/07/01' THEN '2013'
when MSDate > '2013/06/30' and MSDate...
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
May 15, 2015 at 8:25 am
cms9651 (5/14/2015)
I have problem to execute query with interval date.
If try this query I don't have problem and the output is correct:
SELECT * FROM dotable
WHERE
dotableDate...
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
May 14, 2015 at 7:27 am
Have a look at the REPLACE function in Books Online (SQL Server help)
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
May 13, 2015 at 10:08 am
There are at least two alternatives which may perform better than your original. How much better depends to a great extent on indexing:
SELECT t.*, x.SUB_TYPE
FROM #TEMP t
OUTER APPLY (
SELECT...
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
May 13, 2015 at 5:42 am
andrew_dale (4/30/2015)
checking the execution plan, if I run a simple query and include one of the index fields in the where clause...
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
May 12, 2015 at 9:28 am
Remove POST_DT from the GROUP BY.
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
May 11, 2015 at 9:08 am
-- Write the query the simplest way. It doesn't get much simpler than this:
SELECT DISTINCT
created_dttm AS Created_Datetime,
proj_task_id AS Project_Task_Id,
CAST([text] AS VARCHAR(2000)) AS [text]
FROM dbo.P_T
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
May 11, 2015 at 2:08 am
Stephen Knott (5/7/2015)
I didn't yet - but I will.
I have added COMMITTED SNAPSHOT isolation as it was the least invasive - i.e. didn't need to change any...
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
May 7, 2015 at 6:13 am
Stephen Knott (5/4/2015)
IF EXISTS( SELECT based on above criteria )
( UPDATE 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
May 7, 2015 at 5:24 am
-- The WHERE clause must be evaluated for each row in the Stock table
-- in order to determine which rows qualify for the UPDATE.
-- The likelyhood of a table lock...
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
May 5, 2015 at 10:03 am
DROP TABLE #Team
CREATE TABLE #Team
(
[FirstName] [varchar](20) NULL,
[LastName] [varchar] (20) NULL,
[Team] Varchar (20) NULL,
[TransactionID] int,
Price float,
NoofTickets int
) ON [PRIMARY]
INSERT INTO #Team
...
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 30, 2015 at 8:51 am
Have you tried a bog-standard aggregate?
SELECT ColA, ColB, ColC = MAX(ColC)
FROM …
GROUP BY ColA, ColB
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 30, 2015 at 6:37 am
mandirkumar 18293 (4/29/2015)
the sp is using more than 20 tables and too many functions . It is difficult to provide the scripts
Too vague to be of any assistance. 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
April 30, 2015 at 1:42 am
Viewing 15 posts - 2,506 through 2,520 (of 10,143 total)