Forum Replies Created

Viewing 15 posts - 796 through 810 (of 1,413 total)

  • Reply To: Inventory Running Total & calculations

    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

  • Reply To: Inflow / outflow report per day

    Jeff Moden wrote:

    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

  • Reply To: Inflow / outflow report per day

    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

  • Reply To: how to check all the delete and update rules on the foreign keys tables

    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

  • Reply To: Subtract running amount

    Jeff Moden wrote:

    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

  • Reply To: Subtract running amount

    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

  • Reply To: All month/yr when no data across different column combinations.

    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

  • Reply To: Get Particular Date from a Month

    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

  • Reply To: Get Particular Date from a Month

    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

  • Reply To: Get Particular Date from a Month

    Here's a tvf

    drop function if exists dbo.fn_test_scnd_thurs;
    go
    create function dbo.fn_test_scnd_thurs(
    @test_date date)
    returns table
    as return
    select dateadd(day, 9, calc_dt.dt)...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Get Particular Date from a Month

    Jeff Moden wrote:

    I had to take down the previous post because I found a bug in the formula.  Looking for how to fix it.

    Ah I didn't see what was posted.  My...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Get Particular Date from a Month

    Jeff Moden wrote:

    Steve, if you're going to use the fnTally function, you need to tell people where to get it.  Since I use it so often, I just put the link...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Get Particular Date from a Month

    Even if fnTally is not available it's still a useful article to read.  Any table with reliably more than 31 rows could be used tho.   In this case I created...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Get Particular Date from a Month

    When you write "which is followed with..." it seems you're intending it to mean "which follows the..."?   The following has 2 Common Table Expressions: 1) 'test_tues_cte' which contains all of...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: how togetparentchildstring in sql server

    The JSON is oddly formed.  Are you 100% sure this is the format required?  The inner JSON items are in array list format but there's no array wrapper. I don't...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

Viewing 15 posts - 796 through 810 (of 1,413 total)