Viewing 15 posts - 766 through 780 (of 1,424 total)
Why call it "spoofing" and not "mocking"? Is spoofing mocking? Is mocking spoofing?
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
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.
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
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...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
January 15, 2021 at 3:06 am
Does it also restart at 0 when aggregating the days?
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
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
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
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
...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
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 ...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
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 ...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
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...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
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...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
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...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
January 11, 2021 at 5:10 pm
Yes the LAST_VALUE function is a windowing function. One way to summarize would be to use a common table expression.
with lv_cte(PrimaryKey, SearchValue, OtherNumericValue, LastValue) as (
...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
January 8, 2021 at 5:50 pm
There's the LAST_VALUE function. In order to return the "last value" (when the set is ordered by: OVER (ORDER BY ...)) across the entire window of rows (in this case...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
January 8, 2021 at 4:02 pm
Style-wise, the joins are specified in "more specific to less specific" order which imo is not the standard way and it's less read-able. Without knowing anything about the underlying data...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
January 7, 2021 at 6:06 pm
The query references "a couple of joined tables" but the code listed only has 1 table 't' in the FROM clause. The error message "multi-part identifer ..." happens when the...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
January 6, 2021 at 9:08 pm
Viewing 15 posts - 766 through 780 (of 1,424 total)