Forum Replies Created

Viewing 15 posts - 451 through 465 (of 475 total)

  • RE: Customery Survey Query with no Duplicates

    Without something to test this against and using Dwain's tip on the row_number, the following may do what you want

    ;WITH NewIDAllRecords AS (

    SELECT

    jobDB.num AS JobNumber,

    DateAdd(minute, 570, jobDB.entered) AS...

  • RE: LIKE operator with INNER JOIN

    Luis Cazares (11/1/2012)


    Micky,

    Your first query is not sargable and that would make it pretty inefficient compared to the second one. 😉

    True :Whistling:

    Not knowing what the data is for, I suspect...

  • RE: LIKE operator with INNER JOIN

    Assuming that your data is always in the format that you have indicated, you could try

    create table #Table1

    (

    SONumber varchar(10)

    )

    create table #Table2

    (

    SONumber varchar(10)

    )

    insert #Table1

    select '123'

    insert #Table2

    select '123/1'

    select *

    from #Table1 t1

    left...

  • RE: SQL Multiple Pivot

    Luis Cazares (11/1/2012)


    Be careful methexis, because both queries aren't the same. One uses MAX and the other uses SUM. In this case the show the same results but it won't...

  • RE: SQL Multiple Pivot

    Hi

    Does this do what you want? I've used sum to aggregate the WholeACNet.

    SELECT Region_Code,

    [Original],

    [RiverLakes_WWFL],

    [RiverLakesSev123_WWFL]

    FROM TestData

    PIVOT (

    SUM(WholeACNet)

    FOR Description in (

    [Original],

    [RiverLakes_WWFL],

    [RiverLakesSev123_WWFL]

    )

    ) p

  • RE: LEAD - 1

    The only confusion has been pointed out by john.arnott. The alias of the "LEAD (Sales,1) OVER (ORDER BY Sales)" should have been "SalesGoal", not "Sales".

    May be I am interpretting it...

  • RE: 100 Most famous interview Questions and Answers

    {Me} How many columns can a table have?

    {You} 1,024!

    {Me} So why are INSERTs designed to handle up to 4,096 columns?

    {You} {wtf???}

    Something else to go and investigate 😀 Could be...

  • RE: Retrieve data between 2 '.'

    Hi

    I thought I would add in a LIKE query to see how that compared. It wasn't as bad as I thought it would be.

    SELECT @StartTime = GETDATE();

    SELECT @HOLDER...

  • RE: PARSENAME

    Thanks for the question ... also didn't know it existed

  • RE: Dynamic Footers, without dynamic SQL

    Hi

    Rather than a procedure you could try a table valued function along the lines of

    CREATE FUNCTION fnFooter (@p1 varchar(30) )

    RETURNS TABLE AS RETURN

    SELECT FooterID, REPLACE(Footer, '@client', @p1) Footer FROM...

  • RE: A quick query puzzle:

    Be careful, now. Recursive CTE's that count or do other RBAR ops are nearly as bad and sometimes worse than While loops. Please see the following article for...

  • RE: A quick query puzzle:

    S_Kumar_S (10/17/2012)


    Although it works fine but why why do we need the UNION ALL part in the CTE?

    This is a recursive CTE, so it will step through the string and...

  • RE: Using IF condition on Cursor

    Hi Luis

    As Eugene said, this could be replaced without using a cursor with something like the following.

    This example may not be the best way to do it, but it has...

  • RE: Propagating Data Fowards Through Time

    Hi Gabe

    Not sure if this is the logic you want to apply, but you may want to add join clauses for the FundID. Should improve it considerably. I...

  • RE: A quick query puzzle:

    ben.brugman (10/8/2012)


    A small change See in the code.

    (My reason for this change change is: The essential part of the code is only written once, so it is smaller, clearer and...

Viewing 15 posts - 451 through 465 (of 475 total)