Viewing 5 posts - 1 through 5 (of 5 total)
with updatebase_cte (MachineID,RecordedDate,Pressure,ind) as (
select s.MachineID,s.RecordedDate,s.Pressure, 0 as ind
from yourtable s
where s.RecordedDate='2012-10-02'
union all
select s.MachineID,s.RecordedDate,
case when s.Pressure = 0 and sc.Pressure <> 0 then sc.Pressure else s.Pressure end as Pressure,
case when...
December 6, 2012 at 6:45 pm
I put the date into the query to make the Island query similar to the last query you posted. That query will only report the first consecutive month for...
December 6, 2012 at 12:28 pm
mickyT (12/5/2012)
;WITH cte AS (
SELECT name,
DATEADD(mm, - ROW_NUMBER() OVER (ORDER BY name, saledate), saledate) dategroup,
saledate
FROM #sales
WHERE quantity > 2...
December 6, 2012 at 10:08 am
There is a particular problem, let's' say, we just want to find out who sold more then 2 each month in at least two consecutive months and when.
For the above...
December 5, 2012 at 5:41 pm
I know Jeff Moden's solution.
But I assume this way could be faster because there is not sorting for row number.
At least, it is a different solution.
December 5, 2012 at 4:04 pm
Viewing 5 posts - 1 through 5 (of 5 total)