Viewing 15 posts - 496 through 510 (of 1,424 total)
It seems safer to avoid LEAD and LAG because start/stop conditions might repeat within ranges of groups
with
gap_cte as (
select *, iif(v.sgn<>lag(v.sgn) over...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
January 17, 2022 at 4:09 pm
On first read it's not very clear. Having the sample data and expected results makes all the difference. Not sure about the ORDER BY tho
with
Parts_cte(PartId)...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 29, 2021 at 6:33 pm
Questions are offered quite acceptable solutions if only some representative sample data is provided. Make it easy to copy/paste temp table(s) and data. If it's reduced to "here is the...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 28, 2021 at 9:44 pm
Since you're not providing minimally representative data here's a minimally representative query. One important thing missed in the previous attempt was the 'Bias' indicates over/under vs budget based on +/-1. ...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 28, 2021 at 6:32 pm
In general the SIGN function can be useful for "over and under" type situations. It seems like the question was edited maybe idk. Anyway, it seems you're looking for the...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 28, 2021 at 5:31 pm
The LAG function takes up to 3 parameters:
1) Column name (required)
2) Row offset (optional)
3) Default value (optional)
To find 3 +/- consecutive rows with the same sign maybe...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 28, 2021 at 1:37 pm
Redshift is based on an earlier version of Postgres. It was modified to be a columnar database, but it doesn't have many of nice features and functions that were...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 27, 2021 at 1:04 pm
Suppose there's an ordinal column called 'Ord'. The WHERE clause makes sure the "first" row is a "root" ElementID. The OUTER APPLY selects the ElementID to substitute if the row...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 26, 2021 at 1:48 pm
Say I have a table that allows nulls on some columns. As records are added, some columns are filled only say 20% of the time. is there an easy...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 25, 2021 at 3:08 pm
It doesn't seem possible without additional information. In your FIRST_VALUE function the PARTITION BY patid and ORDER BY elementiddate doesn't seem to deterministically define the order of the rows where...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 25, 2021 at 3:05 pm
delete p
from #pat p
where p.ElementID='B'
and exists(select 1
...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 24, 2021 at 5:04 pm
Maybe a DELETE statement like this. [Edit: got rid of window function approach and went with COUNT(*) ]
with rn_cte(PatID, ElementIDDate) as (
select PatID,...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 23, 2021 at 5:55 pm
with recent_cte(HorseName, FinishPosition, RaceDate, Rating) as (
SELECT top 1 with ties HorseName, FinishPosition, RaceDate, Rating
FROM @RACES
...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 23, 2021 at 1:39 pm
Following on what Mr. Brian Gale wrote about a DELETE causing a massive gap in the IDENTITY property of a table. It happens sometimes because things which aren't good sometimes...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 22, 2021 at 6:13 pm
Based on the code I would guess your ExceptionLog table is empty because the error handling issues the ROLLBACK before the error values are accessed. But it's not really guaranteed...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 17, 2021 at 12:59 pm
Viewing 15 posts - 496 through 510 (of 1,424 total)