Viewing 15 posts - 3,211 through 3,225 (of 10,143 total)
Here's a quick rejig of that sample data, and a reformat of the code. Is it only the running total column which is incorrect?
IF OBJECT_ID ('tempdb..#GLT') IS NOT NULL DROP...
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 24, 2014 at 5:21 am
Sachin Nandanwar (6/24/2014)
ChrisM@Work (6/24/2014)
With a duration of 20, this returns an incorrect timeslot (2014-06-23 08:30:00.000 - 2014-06-23 09:15:00.000)No it returns
(2014-06-23 09:15:00.0002014-06-23 10:00:00.000)
Try also DECLARE @duration INT = 120, which...
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 24, 2014 at 4:34 am
Sachin Nandanwar (6/24/2014)
ChrisM@Work (6/24/2014)
With a duration of 20, this returns an incorrect timeslot (2014-06-23 08:30:00.000 - 2014-06-23 09:15:00.000)No it returns
(2014-06-23 09:15:00.0002014-06-23 10:00:00.000)
Sorry, my mistake, I extended the dataset 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
June 24, 2014 at 4:08 am
DECLARE @duration INT=20
SELECT TOP 1
time_sched_start_dt = MAX(CASE WHEN dir = 'S' THEN dt END),
time_sched_end_dt = MAX(CASE WHEN dir = 'E' THEN dt END)
FROM ( -- f
SELECT dir, dt, Grouper...
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 24, 2014 at 2:57 am
Sachin Nandanwar (6/24/2014)
See if this helps.
DECLARE @duration INT=70
SELECT TOP 1 time_sched_start_dt,
...
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 24, 2014 at 2:56 am
Sachin Nandanwar (6/24/2014)
You can use REPLACE function as well.
declare @str as table( val varchar(20))insert @str
select '12-FLA-2-02'
declare @update varchar(20)='11111'
select * from @str
update @str set val=replace(val,LEFT(val, CHARINDEX('-', val)-1) ,@update)
select * from @str
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
June 24, 2014 at 2:04 am
Koen Verbeeck (6/23/2014)
😎 13000th point 😎Also went over 9000 forum posts a while back. :w00t:
Top work geezer, most of 'em are pretty darned good posts 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
June 24, 2014 at 1:47 am
No worries, thanks for the feedback. You'll find some discussion of the method and a link to IBG's original code here.
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 24, 2014 at 1:43 am
Koen Verbeeck (6/23/2014)
chrisn-585491 (6/23/2014)
So, yeah... Sad...
Sad is the word. Sadder still is that at my work a colleague had a bet to guess the background of the author... 🙁
Unfortunately,...
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 23, 2014 at 9:44 am
-- Simplify THE query using (CROSS) APPLY:
select case
when cs.COMMENT like '%CED:%' and DateFilter > convert(varchar(10),getdate(),103) then DateFilter
when cs.COMMENT like '%CED:%' and DateFilter <= convert(varchar(10),getdate(),103) then DateResult
when cs.COMMENT not...
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 23, 2014 at 6:37 am
andrew gothard (6/20/2014)
Ed Wagner (6/20/2014)
andrew gothard (6/20/2014)
Ed Wagner (6/19/2014)
andrew gothard (6/19/2014)
below86 (6/18/2014)
andrew gothard (6/18/2014)
below86 (6/16/2014)
andrew gothard (6/15/2014)
Koen Verbeeck (6/14/2014)
Badly phrased, sorry. In a column that should be a date,...
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 23, 2014 at 5:18 am
pwalter83 (6/23/2014)
ChrisM@Work (6/23/2014)
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 23, 2014 at 5:10 am
Paul, you have two threads open which cover the same problem. Can I suggest you choose one of them and close the other? You can do that by posting something...
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 23, 2014 at 4:25 am
pwalter83 (6/23/2014)
ChrisM@Work (6/23/2014)
pwalter83 (6/23/2014)
... I need to use the following query to get the desired resultset. I think that is where the problem is
If the query you "need to use"...
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 23, 2014 at 3:14 am
pwalter83 (6/23/2014)
... I need to use the following query to get the desired resultset. I think that is where the problem is
If the query you "need to use" doesn't work...
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 23, 2014 at 2:49 am
Viewing 15 posts - 3,211 through 3,225 (of 10,143 total)