Viewing 15 posts - 151 through 165 (of 1,390 total)
Thank you Jeff. 44.9% or 31%? Either way there's no implicit type conversion 🙂
Ken McKelvey's solution in the "Pivot with grouping intervals" topic is interesting. It cross join's a 2...
November 19, 2023 at 1:03 pm
The top two CTEs could be replaced with only one. Possibly the bottom two could be combined as well using the "smudge" method?
with
pvt_cte as (
...
November 17, 2023 at 8:00 pm
Afaik this returns the same output. The CTEs expand the date intervals, pivot by role name and summarize by day, identify gaps in GROUP BY columns, and create groups using...
November 17, 2023 at 6:21 pm
From your query results you could CROSS APPLY a row generator created by using the row cardinality from sys.all_columns (which in my test instance is 11,745 rows) and TOP. The...
November 17, 2023 at 4:23 am
You could test if the modulo .1 of HRS equals zero
;WITH cte_data AS (
SELECT CAST(50.10 AS numeric(5, 2)) AS HRS
...
November 16, 2023 at 5:40 pm
Also there's EOMONTH which has an optional second parameter 'offset'. Regardless of which date/datetime datatype is passed to the EOMONTH function it returns DATE. Ha, some SSC members were wondering...
November 2, 2023 at 1:45 pm
All perfect parents have the same thing in common. No kids
October 25, 2023 at 5:22 pm
Also my code assumes the RequestNo is UNIQUE NOT NULL and has appropriate sequential values. The DDL provided says the RequestNo is NULL-able
October 21, 2023 at 6:02 pm
drop TABLE if exists #F6000059;
go
CREATE TABLE #F6000059
(
[RequestNo] [int] NULL,
[REAN82] [int] NULL,
[REAN83] [int] NULL,
...
October 21, 2023 at 3:57 pm
It seems like you're looking for an UPDATE statement
/* select using OUTER APPLY and TOP(1) */
select t.id, t.code, t.result, prev.result prev_result,
...
October 17, 2023 at 11:04 pm
...
In source table each row is allways for one date, so if the work shift continues over midnight it's broken into two parts. But for expected output the time...
October 17, 2023 at 3:47 pm
Thanks, Drew for your reply. Did you bother to read my latest post? and did you bother to run the query that I provided?
IF yes, then my question was...
October 12, 2023 at 5:58 pm
I also did a comparison of my query with Steve's query. Here are the read stats. Specifically note the scan counts and logical reads on the 'Worktable'.
Using the preceding...
October 12, 2023 at 5:28 pm
Afaik the set up is not clear. This seems to produce the correct result
with
gaps_cte as (
select *, case when crit<>lag(crit) over (order by...
October 12, 2023 at 2:29 am
This took a while, but was fun! There are a couple of characters in this forum who like to come along and make my code run 17 times faster,...
October 10, 2023 at 4:35 pm
Viewing 15 posts - 151 through 165 (of 1,390 total)