Forum Replies Created

Viewing 15 posts - 2,491 through 2,505 (of 4,087 total)

  • RE: Query to track hourwise,daywise,weekwise,Monthwise and yearwise data

    Please provide sample data and expected results as listed in the first link in my signature.

    Drew

  • RE: Finding related records within the same table

    Your rCTE should start with the original stakeholders, instead of starting with the stakeholder that you are interested in, because you only need to traverse the tree in one direction...

  • RE: remove duplicate values in a view , without affecting main tables

    Look up ROW_NUMBER, specifically Example B: Returning a subset of rows. You want to return the subset where the ROW_NUMBER equals 1. You just have to define the...

  • RE: Resources to entity tables relationship

    Boris Pazin (8/4/2016)


    drew.allen (8/4/2016)


    There is another approach, but it's a lot more complicated and I would need the information that the others have requested to make a reasonable attempt at...

  • RE: Resources to entity tables relationship

    Have you considered using SEQUENCE instead of an IDENTITY? Sequences are similar to identities, but they're not tied to a specific table.

    There is another approach, but it's a lot...

  • RE: Help with a PIVOT

    Luis Cazares (8/3/2016)


    drew.allen (8/3/2016)


    Luis Cazares (8/3/2016)


    pnr8uk (8/3/2016)


    What does the u in this line mean?

    ...

  • RE: Help with a PIVOT

    Luis Cazares (8/3/2016)


    pnr8uk (8/3/2016)


    What does the u in this line mean?

    (...

  • RE: nested or hierarchal sql query using FOR XML Path

    You have a main query and three subqueries. The subqueries can only access fields within their scope and the parent's scope. They cannot access fields/tables from the other...

  • RE: inefficient query

    And here is an option changing the last part to a NOT EXISTS. This also assumes that PolicyInsuredLocGK cannot be NULL.

    AND NOT EXISTS (

    SELECT 1

    FROM AIRGBS.vLCExtract AS lc2

    WHERE lc.AccountNum...

  • RE: inefficient query

    scottcabral (8/3/2016)


    i get this:

    Use of DISTINCT is not allowed with the OVER clause

    You can still use windowed functions, but it's a bit more complicated. I would start with something...

  • RE: Help with a PIVOT

    You haven't supplied the expected output, but I suspect you are trying to transpose the data rather than pivot the data. You would need to unpivot followed by a...

  • RE: In-Line TVF Split Function JOIN to Base Tables Optimization

    regan.wick (8/2/2016)


    Thx David

    I read the post you cited. This is the key line from it.

    "3.Use inline TVF when possible: In the demo, it’s unnecessary to use a multi-statement TVF....

  • RE: PLEASE HELP - Pivot just not working

    Part of the problem that you are having is that the IN clause of a PIVOT requires a set of quoted identifiers, but you are supplying expressions. When determining...

  • RE: Need Help with XML

    Jampandu (8/2/2016)


    /*

    -- Expected output

    <?xml version=”1” encoding=”utf-8”?>

    <Batch>

    BatchID=”1” Count=”999” Status=”Errors”

    <Doc>

    Type=”XXX” Code = “XXXX” Number=”xx111” Id=”9999”

    <Error>888</Error>

    <Address>Address1</Address>

    </Doc>

    </Batch>

    */

    Are you sure you don't want your output to look more like this (that is...

  • RE: Add New Column with RowID

    Since you are on SQL 2012, have you considered using LEAD/LAG instead of doing a self-join?

    Drew

Viewing 15 posts - 2,491 through 2,505 (of 4,087 total)