Forum Replies Created

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

  • RE: Find Duplicate Records in Table and Update one of them.

    Con Alexis (5/8/2016)


    Depending on number of rows, and indexes etc... but I would usually do a "GROUP BY" to identify dupes together with MIN to identify original record, then joining...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Date DImension Query

    o103452 (5/6/2016)


    Sergiy (5/5/2016)


    Create a calendar table having a record for each day you company has been or will be filing tax reports.

    Not sure if it's good or bad, but there...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Date DImension Query

    o103452 (5/5/2016)


    Hi guys,

    I'm working on modifying the fiscal date script from here.

    I'm trying to figure out how to calculate the following.

    FiscalWkofQrt

    -- Week # of each querter where it resets every...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Need some help transposing a query

    Given the name MASTER_CODING_RESULTS_ID, it's highly likely that this is the primary key, in which case there is no reason to reference the table more than once.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Need to insert Reocrds in uniqueidentifier column

    If you want a unique identifier with all zeroes, you can always do the following.

    SELECT CAST(0x0 AS UNIQUEIDENTIFIER)

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to show CAPS lock status in Management Studio status bar?

    SQL Prompt will automatically adjust the case, so I don't care whether caps lock is on. Also, it becomes quickly obvious as you're typing that the wrong case is...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Help Using Cursor

    This is my best guess at doing this WITHOUT A CURSOR.

    I combined your two derived tables into one by using the LAG function and removed unnecessary conditions in your CASE...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to generate new Int ID for multiple columns

    Alan.B (5/4/2016)


    ROW_NUMBER does not take ties into consideration, RANK and DENSE_RANK do.

    I would phrase that differently. They all take ties into consideration: RANK and DENSE_RANK treat ties as...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Join the same source tablle twice

    Ed Wagner (5/3/2016)


    I guess I must not understand the question either. From the way I read it, I would do something like this:

    SELECT TOP 2 DateColumn

    FROM dbo.TableName

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: only helpful if people know what it is," said the American

    Reported as spam.

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Get the time difference of 80% of total record

    salliven (5/4/2016)


    Maybe this query?

    ;with cte as (

    select TOP (select ((MD.TotalCount*80)/100) as TotalCount from [dbo].[Message_Identifier] MD where MD.MessageID = 1141)

    DMQD.SubmitDate

    from [dbo]. message_queue_details

    DMM DMM.MessageID = 1141

    order by SubmitDate

    )

    select

    DATEDIFF(SECOND,MIN(SubmitDate), MAX(SubmitDate)) as TimeDiff

    from cte

    I...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: efficient Querying - NOT EXISTS

    ScottPletcher (5/3/2016)


    You need to create an index on ID in T2, T3, T4, T5 and T6.

    You should check the tables in the order of most likely to EXIST first, so...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Historical Date

    PSB (5/3/2016)


    Server is UTC time zone .

    I just need to delete today's records and insert new ones and keep yesterday and older records. Rest (time zone) is not mandatory.

    If the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Find column values based on min and max of other columns

    John Mitchell-245523 (4/29/2016)


    Or this - probably more efficient since it only involves a single scan:

    SELECT DISTINCT

    ID

    ,IDDATE

    ,FIRST_VALUE(FROMID) OVER (PARTITION BY ID, IDDATE ORDER BY JID) AS FROMID

    ,FIRST_VALUE(TOID) OVER (PARTITION BY ID,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: AVG Function not working as expected.

    dhanekulakalyan (4/26/2016)


    Thank you I need to check with ltrim(rtrim(avg(datesdiff))) to get in one row. I will keep you posted .

    LTRIM() will remove leading spaces, RTRIM() will remove trailing spaces....

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

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