Forum Replies Created

Viewing 15 posts - 361 through 375 (of 1,419 total)

  • Reply To: To Which Experts Should You Listen?

    One Youtube channel is the CMU Database Group from Carnegie Mellon University.  My brother went to CMU and one of his sons goes there now.  Their earlier series are...

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

  • Reply To: Find Members who have lost eligibility for more than 3 years or more.........

    To make the comparison between rows you could use the LAG function.  Then use integer division programYearValue/100 to extract the start year and take the modulo 100 of the lagged...

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

  • Reply To: query take long time when execute it so how to solve issue ?

    Why is there no primary key on the extractreports.dbo.partsrecomendationActive table?  You have a clustered index and yet UNIQUE is not specified.   This seems to cause a merge join and it's...

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

  • Reply To: Recursive calculation // calculation column referring to itself

    Regarding the time it takes different member have different approaches.  For me it's usually asap without too much nth degree refactoring.  Whatever gets people unstuck.  I'm a developer too so...

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

  • Reply To: Recursive calculation // calculation column referring to itself

    Happy it helps!  Thanks for the feedback 😊

    It was a medium challenge.  Your follow up post cleared up the lot size issue.  Maybe an hour or so added together.  Estimating...

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

  • Reply To: Recursive calculation // calculation column referring to itself

    Thanks for the further explanation.  This query takes a number of passes at the data due to multiple uses of windowing functions. It assumes 'Item' to be a PARTITION BY...

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

  • Reply To: Recursive calculation // calculation column referring to itself

    Is this the equation?  The change in monthly quantity is labelled as delta_q.

    quantity_on_hand + delta_q + production_proposal - lot_size - minimum_stock = 0

    In month 1:

    quantity_on_hand=4,000, delta_q=0, lot_size=810, and minimum_stock=4050

    4,000+0+production_proposal-810-4050=0

    production_proposal=860

    In month...

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

  • Reply To: SqL query help

    Before calculating the ytd amounts you could first summarize to the month.  Then CROSS APPLY to get ytd amounts

    drop table if exists #myfacttable;
    go
    create table #myfacttable(
    businessdate...

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

  • Reply To: How to get records for the first 15 days of the month

    where OrderDate>=dateadd(day, 1, eomonth(getdate(), -1))
    and OrderDate<datefromparts(year(getdate()), month(getdate()), 16)

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

  • Reply To: Select statement results

    It seems there are 3 compound conditions: 1)  where (drive=c and percentage free<10), or 2) where (drive!=c and percentage free<20), and 3) where not (server=vc5 and drive in (...)).  Maybe...

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

  • Reply To: Using LAG to return prior non null value

    Also add PARTITION BY ID to the SELECT INTO

    SELECT *, 
    LAG(ReportDate) OVER (partition by id ORDER BY ReportDate) LagReportDate,
    ...

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

  • Reply To: Using LAG to return prior non null value

    Chrissy321 wrote:

    Can you provide more detail on what you mean when you say 'add the LAG columns to #MyData'?

    /* Add LAG function columns to the query which...

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

  • Reply To: Using LAG to return prior non null value

    If you add the LAG columns to #MyData you could try CROSS JOIN'ing the calendar rows with the distinct IDs.  Then LEFT JOIN #MyData on id and date.

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

  • Reply To: Stored procedure able to be built over table that doesn't exist

    The behavior is called "late binding" and for many workflows and from many points of view it's a feature and not a flaw.  Early binding is available in SQL Server...

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

  • Reply To: What Do We Want to See in SQL Server?

    The Dark Mode issue is real.  Iirc MS's excuse (for years and years) for not having it has been it would potentially make SSMS unstable.  Disappointing.  Largely due to the...

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

  • Viewing 15 posts - 361 through 375 (of 1,419 total)