Forum Replies Created

Viewing 15 posts - 9,826 through 9,840 (of 10,144 total)

  • RE: Help Optimizing Query?

    Hi Pop

    SELECT a.casenum, a.audit_date, c.audit_date as StartDate, a.stepname

    ...

  • RE: Help Optimizing Query?

    So you want the cases having their most recent step in your list of stepnames? Sorry to be a pain!

  • RE: Help Optimizing Query?

    Cool, many thanks Pop.

    Got a question for you:

    SELECT ...

  • RE: eliminating duplicates

    Oh all right then. No funny stuff either.

    DECLARE @ItemID INT

    DECLARE @FirstCol varChar(5), @SecondCol INT, @ThirdCol Char(1)

    SET @ItemID = 1

    UPDATE #Testing SET ThirdCol = CASE @ItemID WHEN 1 THEN 'D'...

  • RE: quirk of nulls & blanks using aggregate function

    Hi Tim

    I use the ASCII function for this, usually the first two characters of the column...

    DECLARE @tempvar VARCHAR(5)

    SET @tempvar = CHAR(10) + CHAR(13)

    SELECT ASCII(LEFT(@tempvar,1)), ASCII(SUBSTRING(@tempvar,2,1))

    Cheers

    ChrisM

  • RE: eliminating duplicates

    Shaun McGuile (7/1/2008)


    the point of the exercise -

    ...so all that is left is a table full of records which were duplicated at least once!

    Misleading title though....;)

    Jeff, Chris; It falls...

  • RE: eliminating duplicates

    lmarcum (7/1/2008)


    It is not impossible. Add an identity column. Each record will be numbered. Then use the identity column to delete the duplicate records.

    Read the OP's second...

  • RE: eliminating duplicates

    Jeff Moden (7/1/2008)


    You guys are missing the point of this particular exercise... despite the name of the post, this is NOT about the elimination of duplicates. Here's what the...

  • RE: Help Optimizing Query?

    Pop

    Your sample data doesn't return any rows. This chunk...

    SELECT ...

  • RE: eliminating duplicates

    mlando.mngomezulu (7/1/2008)


    Actually the first step makes sure that the temptable only have one record per corresponding duplicate records. This is achieved by the "group by" clause. This is grouped...

  • RE: eliminating duplicates

    mlando.mngomezulu (7/1/2008)


    Step1: You need to create a table containing only the duplicate records by first selecting all the duplicate records into a new table i.e.

    Insert into temptable...

  • RE: eliminating duplicates

    Nicking Barry's excellent idea (and Janines test data), here's another way which is quite fast:

    DROP TABLE #Testing

    CREATE TABLE #Testing (

    FirstCol varChar(5),

    ...

  • RE: what date format is this?

    Jeff Moden (6/26/2008)


    Heh... no problem... if you think no coffee is bad, I'm trying to quit smoking... got anyone you want to take to a porkchop dinner? 😀

    Ahah that explains...

  • RE: INNER JOIN on TOP 1

    Mark (6/24/2008)


    Another alternative

    SELECT

    A.RetailerID,

    X.RetailerIDTheirs

    FROM TableA AS A

    CROSS APPLY (SELECT TOP 1 B.RetailerIDTheirs FROM TableB B...

  • RE: INNER JOIN on TOP 1

    Hi Simon

    This is simple but somewhat restrictive:

    SELECT A.RetailerID, MIN(B.RetailerIDTheirs) AS RetailerIDTheirs

    FROM #TableA A

    LEFT JOIN #TableB B ON B.RetailerID = A.RetailerID

    GROUP BY A.RetailerID

    This is less simple but offers more flexibility:

    SELECT...

Viewing 15 posts - 9,826 through 9,840 (of 10,144 total)