Forum Replies Created

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

  • 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: Introduction about me

    Here's a bump.  It's not possible imo to be of much "what to do" help because it's uniquely situational.  Afaik WordPress only supports the MySQL database.  My information could be...

    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

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

    Maybe you could add the LAG columns to #MyData.  Then use a combination of LAG and MAX OVER.  If this were SQL Server 2022 you could use the WINDOW clause

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

  • Reply To: sys.object

    Have a look at the Docs on "Multipart Names"

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

  • Reply To: sys.object

    The variable @ObjectName provided as an example was not plural such that it corresponds to an actual system object.  Try it with N'sys.objects' instead of N'sys.object'.  YOU NEED TO PROVIDE...

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

  • Reply To: Error converting data type varchar to numeric issue

    If it's the code in your picture which produced the error message then your probable issue imo is a type mismatch between the join columns.  Either ar.S1WHS# or wf.L3WHS# is...

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

  • Reply To: Error converting data type varchar to numeric issue

    You could try using TRY_CAST to determine which row values are causing the CAST to fail

    select *
    from YourTable
    where TRY_CAST(MASTER_BOL_NUMBER as numeric) is null;

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

  • Reply To: Create a Tally Function (fnTally)

    What about making datatype specific fnTally-ies?  Many times the maximum requirement is less than BIGINT.  What about fnTallySmalldatetime, fnTallyDatetime?  What about making separate 0+ version and 1+ versions?

    Any editorial regarding...

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

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