Forum Replies Created

Viewing 15 posts - 91 through 105 (of 113 total)

  • RE: Brain Fried on a JOIN Question

    The issue could be related to the nullability of some of the columns. The are different ways to tackle this but using CHECKSUM is not one of them because the...

  • RE: Searching for n-categories

    This problem is known as Relational Divsion[/url].

    There is the exact division (only 3 and 6) and the one with a remainder (at least 3 and 6). Yours seems to be...

  • RE: compare rows

    It is very helpful to include table definition, sample data in the form of "insert" statements and expected result. That way we don't have to guess column names, data types,...

  • RE: Problem with writing a query. Kindly guide...

    This problem is known as Relational Division[/url].

    SET NOCOUNT ON;

    USE tempdb;

    GO

    DECLARE @T TABLE (

    Rate int NOT NULL,

    Shift int NOT NULL,

    PRIMARY KEY (Rate, Shift)

    );

    INSERT INTO @T (

    Rate,

    Shift

    )

    VALUES

    (1, 1),

    (1, 2),

    (1, 3),

    (2, 5),

    (3,...

  • RE: Query

    You can use some of the string functions like CHARINDEX, PATINDEX, LEFT, SUBSTRING, etc.

    Try to find the first non numeric character and extract the substring from the beginning to this...

  • RE: Build menu with CTE ....

    I changed [path] by order_val in the recursive part and now it should run flawless.

    A recursive CTE is still an iterative approach so I do not hold my breath hoping...

  • RE: T-SQl help...

    This problem is known as "Finding Islands", but this case is a special one because there is no other column that we could use to break ties based on (CID,...

  • RE: Build menu with CTE ....

    One way to accomplish this is using a varbinary column to concatenate the sequence of numbers based on the position value.

    WITH C1 AS (

    SELECT

    Id, IdRoot, Name, Position,

    CAST(ROW_NUMBER() OVER(ORDER BY...

  • RE: Finding gaps within date ranges

    Thanks, Dwain!

    --

    AMB

  • RE: Max Consecutive Dates Without an Exclusion Date

    Since you are using SS2012, here is a possible solution using the offset function LEAD.

    Supposing all exclusions are inside the order interval, the idea is to generate the intervals between...

  • RE: Finding gaps within date ranges

    Sorry for the formatting but I have no idea how to post T-SQL code.

  • RE: Finding gaps within date ranges

    The approach I would use is first to pack overlapping intervals and then find the gaps.

    You can read about both methods in the last book from Itzik Ben-Gan about "High...

  • RE: Removing Overlapping periods

    If I understood it correctly, you want groups of 63 rows supposing they are consecutives and then select the first row for each group.

    WITH T AS (

    SELECT

    ...

  • RE: T-SQL Pvot Data and Hide duplicates

    If you have maximum one comment per (Dealer, Year, Month, Car_Id) then you can enumerate the rows and then use a FULL OUTER JOIN.

    SET NOCOUNT ON;

    USE tempdb;

    GO

    DECLARE @T1 TABLE (

    Camry_Id...

  • RE: How to Fatch last maximum non-zero values

    What version of SQL Server are you using?

    I am not sure is you are looking for the last non-zero value or the maximum non-zero value. Anyway, filter the rows to...

Viewing 15 posts - 91 through 105 (of 113 total)