Forum Replies Created

Viewing 15 posts - 2,071 through 2,085 (of 4,085 total)

  • RE: Compare subset with subset in same table

    Phil Parkin (12/22/2016)


    IF OBJECT_ID('tempdb..#tmp', 'U') IS NOT NULL

    DROP TABLE #tmp;

    CREATE TABLE #tmp

    (

    FormulaId CHAR(2)

    , IngredientId CHAR(2)

    );

    INSERT #tmp

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: LEFT JOINS WITH INNER JOINS

    Not necessarily. The problem is when a field from an outer table is used in a JOIN condition (or WHERE clause) without taking into account that it might be...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Windowing function with conditions?

    Thom A (12/22/2016)


    Fully Windowed, and VALID included.

    WITH CTE (EVENT_ID, EVENT_RANK, MIN_AGE, MAX_AGE, C_MIN, C_MAX) AS

    (

    SELECT A.EVENT_ID,

    A.EVENT_RANK,

    A.MIN_AGE,

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Today's Random Word!

    Manic Star (12/21/2016)


    jasona.work (12/21/2016)


    Ed Wagner (12/21/2016)


    jasona.work (12/21/2016)


    Ed Wagner (12/21/2016)


    Revenant (12/21/2016)


    Gulf

    Fishing

    Ice

    Lake

    Huron

    Bird

    Archeopteryx

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Need Help deserializing this XML string

    Something along the lines of the following.

    SELECT c.value('@name', 'VARCHAR(50)')

    FROM @doc.nodes('/xs:schema/xs:element/xs:complexType/xs:sequence/xs:element[2]/xs:complexType/xs:sequence/xs:element[1]/xs:complexType/xs:sequence/xs:element') T(c)

    You may need to use a CROSS APPLY if the XML is stored in a column instead of a variable....

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Query help filling in dates and data

    whenriksen (12/21/2016)


    DK13 (12/20/2016)


    NULL is a valid action type.

    I'll save Celko the effort here. NULL is not a valid action type. It is messing up your results because you...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Trying to rank the 0.000 data as well

    You're using a subquery to get the rank when you should be using ROW_NUMBER().

    /*ranking*/

    SELECT compmcd.hedismeasure,

    compmcd.measureid,

    compmcd.competitor,

    compmcd.market,

    compmcd.prodabbrev,

    compmcd.hedisrate,

    ROW_NUMBER() OVER(PARTITION BY measureid, market, prodabbrev ORDER BY hedisrate DESC, measureid DESC ) AS rn

    FROM...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to modify query to only use base tables

    matthew.livingston (12/20/2016)


    Not sure if it is okay to post this here, but if this is correct, it will help everyone understand better. OP could help verify.

    http://mica.edu.vn/perso/kiendt/doc/EE4253-EE6133/Database%20Design,%20Application%20Development,%20and%20Administration.pdf

    pages 365-367

    Yes, it looks like...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Query help filling in dates and data

    sgmunson (12/20/2016)


    Just another way to tackle it, using CROSS APPLY:

    -- code snipped to pinpoint this section

    SELECT D.*,

    CAST(D.[Date] AS date) AS DATE_ONLY,

    CASE

    WHEN CAST(LEAD(D.[Date], 1, '9999-12-31') OVER(ORDER BY D.[Date]) AS date) =...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Query help filling in dates and data

    Jason A. Long (12/20/2016)


    This is based on an old(ish) Itzik Ben-Gan solution... The Last non NULL Puzzle

    IF OBJECT_ID('tempdb..#Data', 'U') IS NOT NULL

    DROP TABLE #Data;

    CREATE TABLE #Data (

    ID VARCHAR(20),

    SEQ INT,

    Date...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Overlapping datetime ranges.

    Most approaches that I've seen collapse the ranges. That is, they don't retain a record with a zero length. Is there a particular reason that you need to...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Query help filling in dates and data

    Your DateKey is defined as INT. Don't provide your sample data as CHAR, because it forces an implicit conversion.

    You say that your data contains NULLs which are causing you...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Query help

    Brad Feaker-195979 (12/20/2016)


    Got the same results - but thanks...

    The query I gave you will produce a row with NULL values for the grouped fields. Since your results DO NOT...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Query help

    I suspect what you want is

    GROUP BY GROUPING SETS((EDI_Batch_Number, Reference_2),())

    which will give you groups by EDI_Batch_Number/Reference and then a grand total.

    What you currently have gives your one group on...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: A Fun Distraction

    jasona.work (12/19/2016)


    Phil Parkin (12/19/2016)


    jasona.work (12/19/2016)


    Rouge 1 (have now saw it twice)

    So you should certainly know how to spell it by now! :hehe:

    *I* spelled it correctly, just check the post!

    (and ignore...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 2,071 through 2,085 (of 4,085 total)