Viewing 15 posts - 796 through 810 (of 1,419 total)
I did find some old documentation for SQL Server 2005 which says the SUM function may be followed by the OVER clause.
Yep... and I didn't...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 12, 2020 at 3:30 pm
thanks for the response but I need it only with a nested while loop.
Don't re-use @I. Come up with a new variable to store the counter for the inner...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 11, 2020 at 5:32 pm
To fix the first issue you could add 'order_num' to the GROUP BY clause.
Not sure why 'Dry Feed' doesn't show. It's using an equivalent of the 'Dry Feed' WHERE clause...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 11, 2020 at 5:20 pm
Why is this necessary? Here's a solution using (two of) the fnTally function to generate the rows instead of WHILE loops. Re-using declared variables is generally not a good...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 11, 2020 at 3:16 pm
Sorry it's been a busy day! Please give this a try
declare
@start datetime='2020-11-29 00:00:00.000',
@end ...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 11, 2020 at 12:46 am
The second post makes the first one clearer. In the first post the 2nd query in the statement containing UNION ALL is the only place where 'Dry Feed' is defined...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 10, 2020 at 3:12 pm
It's not fully explained imo. The SELECT above the UNION ALL is summarizing 'Wet Feed' tons per hour? The SELECT below the UNION ALL is 'Dry Feed'? It appears you're...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 9, 2020 at 10:28 pm
Again, can't use SUM() OVER for the running total on this one. The OP said he's actually using 2005.
The OP said they're going to migrate to a newer version. ...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 9, 2020 at 7:44 pm
After the update the code could look something like this
drop TABLE if exists #Invoices
go
CREATE TABLE #Invoices(
[InvoiceID] [int] IDENTITY(1,1) NOT NULL,
[InvoiceDate] [smalldatetime] NULL,
[Total] [decimal](18, 2) NULL,
CONSTRAINT [PK_Invoices] PRIMARY...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 9, 2020 at 3:45 pm
The lazy programmers' way to delete from complex data structures is to get a data comparison tool to generate the SQL DELETE transaction. Where I work we've used 2 different...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 9, 2020 at 2:56 pm
Steve... the OP has posted in a 2005 forum which is before SUM() OVER had the ability to produce a running sum. I'm thinking we're going to need another...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 9, 2020 at 1:41 pm
You could try something like this
drop table if exists #MyTempTable
go
create table #MyTempTable(
EE int not null,
EffDate ...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 9, 2020 at 2:09 am
When "trying to get all combinations..." it usually means CROSS JOIN. In this case the distinct year/month dates are selected in the CTE. Then the CTE is 'row multiplied' or...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
December 3, 2020 at 2:56 am
Oh wait I think I see what you're saying now. It should subtract 2 days from the current month 2nd Thursday to compare with the current date. The query could...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
November 30, 2020 at 11:01 pm
It depends on what the "today" date is, no?
CASE 2 - If Today is 1 Dec 2020 - Then, The output should be (12 Nov 2020) -
Reason, 10 Dec 2020...
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
November 30, 2020 at 10:45 pm
Viewing 15 posts - 796 through 810 (of 1,419 total)