Viewing 15 posts - 151 through 165 (of 1,396 total)
If you want the odd numbered 'rotation' column value(d) rows to be updated from the even numbered rows then LAG would seem the better choice. First tho, I agree with...
December 5, 2023 at 1:26 pm
Maybe something like this. The OUTER APPLY looks for the next occurrence of [Status] in('collected', 'shipper') for each dropoff and preparation. Also, LEAD(DateShipped) looks for the next occurrence of [Status]...
November 30, 2023 at 5:42 pm
Maybe get rid of the MAX OVER and just evaluate the Status column
select *, iif([Status] in('Dropoff', 'preparation'), 1, 0) d_or_p
from #ShipperStatusHistory
order by OrderNumber, DateShipper; November 30, 2023 at 2:48 am
Happy Thanksgiving
Based on the written requirements (as interpreted) this query might be helpful. The comparisons being made across rows are partitioned by (OrderNumber, RelayPoint) and ordered by DateShipper. To identify...
November 25, 2023 at 2:23 am
The date columns are of data type DATE? It's not confirmed by question. For this answer the dates must be stored as DATE.
;with example_cte as (
...
November 22, 2023 at 1:53 pm
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
Viewing 15 posts - 151 through 165 (of 1,396 total)