Viewing 15 posts - 736 through 750 (of 1,398 total)
This is sort of confusing because the ORDER BY of the outermost query includes the 'head' column as well as 'Trans_ID'. The SUM OVER ORDER BY is only by '(select...
January 26, 2021 at 8:13 pm
This comes really close. It uses a FULL JOIN which is functionally both a LEFT JOIN and a RIGHT JOIN. It seems the example Status_ToolType column might have some consistency...
January 24, 2021 at 10:17 pm
Maybe the correlated subquery in the WHERE clause is converting your LEFT JOIN into an INNER JOIN. Maybe try expressing OBS as OUTER APPLY SELECT TOP(1) ... instead.
January 24, 2021 at 6:08 pm
Why call it "spoofing" and not "mocking"? Is spoofing mocking? Is mocking spoofing?
January 20, 2021 at 3:37 pm
Instead of approximating the "current" date by selecting the MAX(date) the code could reference CAST(GETDATE() as DATE) to access the system datetime and cast it as type DATE.
January 18, 2021 at 6:14 pm
Ugh it's dependent on calculated row values. Although painful to create, here's a WHILE loop which populates a new table '#myNewTable' with the ID and the derived theoretical_cycle column. It's...
January 15, 2021 at 3:06 am
Does it also restart at 0 when aggregating the days?
January 14, 2021 at 10:26 pm
The 'max_val' column matches the 'Days_Cycle' column in the table provided. The 'theoritical_cycle' (in rows where ID is greater than 19) doesn't seem to follow the rules you're suggesting
January 14, 2021 at 7:21 pm
Integer division comes in handy when creating groupings based on ranges of integers, aka "buckets". Something like this
select t.*, v.*, cycle.*
from #mytable t
...
January 14, 2021 at 5:33 pm
Well well, this is the first time I can recall ever using a RIGHT JOIN in a "real" query. It seems to make sense here.
declare @dt ...
January 12, 2021 at 5:40 pm
The data looks something like this?
drop table if exists #conditions;
go
create table #conditions(
some_dt date not null,
code ...
January 12, 2021 at 5:06 pm
DECLARE @v_order_id INT = 1;
WITH
myData AS(
SELECT 'all_codes_set' AS code_type,
1 AS start_id,
100 AS end_id,
1 AS order_id
UNION ALL
SELECT 'all_codes_set' AS code_type,
101 AS start_id,
110 AS end_id,
2 AS order_id
UNION...
January 11, 2021 at 6:13 pm
Ok, the non-tvf same approach uses an additional CTE and SELECT TOP(n). The following code is to be embedded in the SQL to replace dbo.fnTally. The maximum # of rows...
January 11, 2021 at 6:05 pm
The fastest way to reliably get an answer is not necessarily the "best" way but it's functional. Afaik something like this would work. It uses a tally function to expand...
January 11, 2021 at 5:10 pm
Viewing 15 posts - 736 through 750 (of 1,398 total)