Forum Replies Created

Viewing 15 posts - 4,321 through 4,335 (of 10,144 total)

  • RE: Help with SQL query

    SELECT op, SUM(CASE WHEN dupes > 1 THEN 1 ELSE 0 END)

    FROM (

    SELECT op, imei, dupes = COUNT(*)

    FROM #mastertab

    GROUP BY op, imei

    ) d

    GROUP BY op

  • RE: DATEADD Requirement

    Use an inline tally table as a row generator. Generate the week-based rows and the month-based rows separately:

    DROP TABLE #dates

    CREATE TABLE #dates (date_debut DATE,date_end DATE)

    DECLARE @date_start DATE, @date_end DATE,...

  • RE: Date Validations?

    John Mitchell-245523 (7/22/2013)


    You have a date stored as varchar or similar and you want to check it's a valid date?

    Two options - the first being vastly more preferable:

    (1) Don't store...

  • RE: Date Validations?

    Can you provide more information about the context please Ananth? For instance, are you designing a validation process for an import of a text-typed date?

  • RE: previous week query 0700 - 0700

    jerome.morris (7/19/2013)


    Ok Chris, I think I understand, but when I remove the simple data based on my table and use the real table it returns no results

    It does return results:

    ChrisM@Work...

  • RE: SQL How to use CASE with a NOT EXISTS statement

    There's scope for improvement but without ddl/execution plan it's a long shot. Try this:

    SELECT

    t.TradeId,

    CASE WHEN x.OtpTradeId IS NULL THEN 'Y' Else 'N' End As 'TCM'

    FROM Trade t

    OUTER APPLY...

  • RE: previous week query 0700 - 0700

    It creates a CTE consisting of a single datetime column - a very simple sample data set of your docket table.

  • RE: Invalid column name?

    krypto69 (7/19/2013)


    geez..thanks Chris...need to get some coffee..

    Can I have some too? 🙂

  • RE: previous week query 0700 - 0700

    What was the problem again? 😀

  • RE: Invalid column name?

    You're renamed the column to [Earn Code] in the inner select.

  • RE: previous week query 0700 - 0700

    Cool, now post this code into the same ssms window underneath the rest of the code and run the lot as one batch:

    SELECT *

    FROM dbo.DocketTB

    CROSS APPLY (

    SELECT MondayLastWeek =...

  • RE: Identity property

    Steve-3_5_7_9 (7/19/2013)


    kapil_kk (7/19/2013)


    NO you cant add the IDENTITY property to the existing column using a sql query....

    But it can be done from edit design of a table

    Of course you can....

  • RE: previous week query 0700 - 0700

    Curious...ok, paste this whole batch into a new ssms window and execute:

    DECLARE @RangeStart DATETIME, @RangeEnd DATETIME

    SELECT

    @RangeStart = x1.MondayLastWeek,

    @RangeEnd = DATEADD(DD,7,x1.MondayLastWeek)

    FROM (

    SELECT MondayLastWeek = DATEADD(hh,7,CAST(CAST(DATEADD(DD,-((DATEDIFF(DD,0,GETDATE())%7)+7),GETDATE()) AS DATE) AS DATETIME))

    )...

  • RE: SQL How to use CASE with a NOT EXISTS statement

    Like this?

    With subCA As (

    Select distinct

    OTPTradeId,

    ConfoAuditSenderRef

    from ConfirmationAudit

    where ConfoAuditSenderRef like 'HBEUM%'

    ),

    TCM As (

    Select distinct

    OTPTradeID

    from subCA

    union ALL

    select TradeId

    from subCA

    inner join ConfirmationSent

    on...

  • RE: previous week query 0700 - 0700

    jerome.morris (7/19/2013)


    Point taken Chris, but even if I did I wouldn't get results as I don't them in in the SSMS query?

    Check:

    SELECT TOP 100 Docket_EngFinish

    FROM DocketTB

    ORDER BY Docket_EngFinish DESC

Viewing 15 posts - 4,321 through 4,335 (of 10,144 total)