Forum Replies Created

Viewing 15 posts - 6,436 through 6,450 (of 10,144 total)

  • RE: how to join two tables with non equal conditions?

    Slightly tested:

    SELECT aYr, bYr, aCol, bCol

    FROM #A a

    CROSS APPLY (

    SELECT MAX_bYr = MAX(bYr) FROM #b) x

    INNER JOIN #b b

    ON b.bYr = CASE WHEN a.aYr <= MAX_bYr THEN a.aYr ELSE...

  • RE: Aggregating monthly sales data by column

    Usman Butt (12/1/2011)


    ChrisM@Work (12/1/2011)


    Use a crosstab, preaggregating the raw table with either a CTE or a derived table. Here's the derived table version:

    SELECT

    ItemCode,

    Column1 = MAX(CASE WHEN YearShipped = 2010...

  • RE: Aggregating monthly sales data by column

    Use a crosstab, preaggregating the raw table with either a CTE or a derived table. Here's the derived table version:

    SELECT

    ItemCode,

    Column1 = MAX(CASE WHEN YearShipped = 2010 AND MonthShipped =...

  • RE: need help with query to select with subquery

    Denise McMillan (11/30/2011)


    I got it to work by joining just on the left 4 charracters of the number in the subquery.

    select number, avalue, (select x.nvalue from valuestbl as...

  • RE: Complex View using repeating groups

    Hey Jon, thanks loads for posting up sample data - it took a moment to tweak the script but no worries. Try this:

    ;WITH CTE AS (

    SELECT

    ID,

    ProjectID,

    rowDescription,

    [Year],...

  • RE: Complex View using repeating groups

    Hi Jon, welcome to the forum.

    Can you post up some sample data? There's a link in my sig which shows how to do this - well worth a read for...

  • RE: T-SQL , Stored Procedures & Performance Tuning

    alaguganesha1983 (11/30/2011)


    T-SQL , Stored Procedures & Performance Tuning:

    I need clear idea and good example for the above topic i mentioned.

    help me with this please.

    Acquiring sufficient experience, knowledge and understanding of...

  • RE: getting multivalue from a function

    ashkan siroos (11/29/2011)


    I have Changed my query to avoid cross apply because of the efficiency ...

    CROSS/OUTER APPLY can be surprisingly efficient - read the excellent articles written by Paul White,...

  • RE: getting multivalue from a function

    FROM

    .

    .

    .

    CROSS APPLY (

    SELECT poi.POIDescription, rn = ROW_NUMBER() OVER(ORDER BY r.RequestCode desc)

    FROM DMSRequestDocListTbl rdl

    INNER JOIN DMSRequestTbl r

    ON rdl.RequestCode = r.RequestCode

    AND r.RequestTypeID in ( 8,9)

    AND r.DocRevID = @DocRevID...

  • RE: getting multivalue from a function

    Try using Cross/Outer Apply.

    You can easily convert the content into an inline TVF.

  • RE: DELETE !!! soft ? or Hard ?

    Using a temp table containing the PK's of the target table looks like the best option to me:

    SELECT sec_no

    INTO #sec_no_to_delete

    FROM sec_returns m

    WHERE NOT EXISTS (

    SELECT 1

    FROM sec_returns

    WHERE...

  • RE: Today's Random Word!

    Evil Kraig F (11/22/2011)


    SQLRNNR (11/22/2011)


    riddle

    Question Mark

    Mark is innocent!

  • RE: Order by, displaying results out of order.

    Jorge Lopes (11/28/2011)


    There is a slight problem in the third Select statement you have to put 2 spaces between Balanço and ANO

    SELECT 'Balanço[space][space]ANO'

    CREATE TABLE #desc

    ( NAME VARCHAR(100))

    INSERT INTO #desc

    SELECT...

  • RE: Order by, displaying results out of order.

    DROP TABLE #desc

    CREATE TABLE #desc

    ( NAME VARCHAR(100))

    INSERT INTO #desc

    SELECT 'Balanço- Activo não corrente' UNION ALL -- note changed position of hyphen

    SELECT 'Balanço - Autonomia Financeira' UNION ALL

    SELECT 'Balanço ANO'

    SELECT

    NAME,...

  • RE: Order by, displaying results out of order.

    Character position 9 of two of your strings is a hyphen. There are ways to get around this, for instance you could remove the hyphen and a white space using...

Viewing 15 posts - 6,436 through 6,450 (of 10,144 total)