Forum Replies Created

Viewing 15 posts - 406 through 420 (of 1,419 total)

  • Reply To: T-SQL : Slicing time Islands and gaps

    MrRobot wrote:

    Hi,

    I did the query as bellow i don't know if will perfectly work for another data but with my sample data is work fine just one problem when i...

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

  • Reply To: T-SQL : Slicing time Islands and gaps

    You're saying "split my data" but you've provided 9 rows of input data of which 8 rows do not (seemingly) require splitting.  Does my query correctly separate rows which DO...

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

  • Reply To: T-SQL : Slicing time Islands and gaps

    Step1: convert the dates from INT to DATE

    In  #table1 the date ranges overlap.  How to get rid of the overlaps?  My code updates t1 (my guess is the ranges are...

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

  • Reply To: How do I add an exclusion to a query?

    Phil Parkin wrote:

    The logical equivalent of

    NOT (A AND B)

    is

    NOT A OR NOT B

    It's De Morgan's Law.  The negation of a conjunction is the disjunction of the negations

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

  • Reply To: Help parsing a fields value to create 3 new columns

    JObject seems to be a JSON object so you could use JSON_VALUE to select the fields

    declare @json          ...

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

  • Reply To: Previous Week data to current week data

    As a single statement something similar to the query posted earlier.  As has been mentioned more than once the WeekNo column in the example data is not sortable and it's...

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

  • Reply To: Datefirst format

    Not to could/would come up with it to begin with.  Refactored to remove the CTE's.  The test returns no rows

    DROP FUNCTION IF EXISTS dbo.CalendarByDateFirstRefactored;
    go
    CREATE FUNCTION dbo.CalendarByDateFirstRefactored
    ...

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

  • Reply To: Datefirst format

    LearnSQL wrote:

    Any suggestions or thoughts.

     

    The function seems to generate the correct calendar.  Nicely done Jeff 🙂

    select * from dbo.CalendarByDateFirst('20211201', '20220131', 7);

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

  • Reply To: Datefirst format

    When I paste the OP's latest code into VS and run it it generates an incorrect calendar table.  My interpretation of the OP's unresponsiveness amounts to "just make my kludge...

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

  • Reply To: How should I use SQL to normalize my tables?

    The tricky part of normalization is populating the tables imo.  A lot of times it's an attempt to establish foreign key referential integrity post priori (after the fact).   You could...

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

  • Reply To: Datefirst format

    I'm still thrown off by week 53.  What?  How does this work?  This topic is the same as this other one I'm assuming

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

  • Reply To: Previous Week data to current week data

    These are ISO weeks?  If so filling in gaps using a tally function is probably not a good approach imo.  Needs a calendar table

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

  • Reply To: Previous Week data to current week data

    In the original question above the WeekNo column is CHAR(3).  In your response to Phil I did not read past the word "Yes" (which is the 1st word) because it...

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

  • Reply To: Previous Week data to current week data

    Suppose your 'WeekNo' column contains a 'W' and maybe/(maybe not) a '-' and the leading 0's and spaces are all over the place.  The key calculation is the numeric wk_num...

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

  • Reply To: How to make select Dense Rank over max of TechnologyId Based on FeatureString Fo

    In which table is TechnologyId primary key?   Is there a linear dependency between PartId and TechnologyId?  Typically in general, if it's necessary to count (or rank) rows in order to...

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

Viewing 15 posts - 406 through 420 (of 1,419 total)