Forum Replies Created

Viewing 15 posts - 6,676 through 6,690 (of 8,755 total)

  • RE: Sum values with an If?

    Quick suggestion, use a case statement

    😎

    USE tempdb;

    GO

    create table dbo.fun_test(

    packtype nvarchar(50),

    price money)

    insert into dbo.fun_test

    values ('Single','2'),('Monthly','25.00'),('Monthly','27.00'),('Monthly','23.50'),('Single','2'),('Deposit','1'),('Deposit','2')

    select

    PackType

    ,count(*) as Records

    ,sum(CASE ...

  • RE: do you have a StripNonNumeric ITVF function?

    Little clean up in the logic, now it looks pretty good

    😎

    /********************************************************************

    -- Stripping out any non-numerical characters

    -- EE 2014-10-28 Inital coding

    -- EE ...

  • RE: SQL Injection Attack

    Looks like this is coming from sqlmap (sqlmap.org), automated injection tool.

    😎

  • RE: combine ROW_NUMBER and COUNT(*) OVER Partition

    SQL Server's implementation of the window functions does not allow for sharing window specification (over clause specs) between functions.

    😎

  • RE: do you have a StripNonNumeric ITVF function?

    Here is my attempt from the train journey to work this morning, looks like it will give the while loop a real run for the money.

    😎

    /********************************************************************

    -- Stripping out any...

  • RE: Finding First and Last Event

    Nice problem, just what's needed to get the brain started in the morning:-D

    😎

    /* BASE_DATA brings together everything that is needed, adds

    a group identifier for...

  • RE: Rank duplicates, but only rows involved in duplicates

    Some test results, looks like the computed column method is roughly 4 times faster than the next one

    😎

    Beginning execution loop

    --============================================================================================================

    -- Method 1 by sqlslacker

    -- ...

  • RE: Rank duplicates, but only rows involved in duplicates

    Chipping in a little more, another method is a computed column and an index on that column, here is a script adapted to fit Jeff's test harness, append it at...

  • RE: Help with TSQL Case Statement. Urgent Help Please.

    Quick thought, embed the case statement in a CTE and then do the aggregations on the output.

    😎

  • RE: Rank duplicates, but only rows involved in duplicates

    Quick note, if the ROW_NUMBER function has a satisfying index to work on it is not expensive at all, consider the code below which only does one index scan and...

  • RE: Rank duplicates, but only rows involved in duplicates

    Jeff Moden (10/25/2014)


    Eirikur Eiriksson (10/25/2014)


    Keep in mind, there's no such thing as a bad code (if it works), your efforts are as worthy as mine any given day, keep up...

  • RE: round to two digit after decimel

    QQ-485619 (10/26/2014)


    what if that is a column name, e.g.

    select sum(saletotal)/NumberofDays

    Either to an explicit type cast to numeric or float using cast or convert or multiply the column value with 1.0,...

  • RE: SQL Query - Should be easy fix???

    j.hoube (10/26/2014)


    Not a problem replaced with AND statement instead of ON seems to have resolved it 🙂

    Thanks for the help and your time

    J

    Sorry about the error, quick copy/paste without checking...

  • RE: round to two digit after decimel

    QQ-485619 (10/26/2014)


    I run the following statement: select 1/3 and I got 0.

    How do I do so that I can get 0.33?

    Thanks,

    Jian

    SQL Server performs an Integer division on whole...

  • RE: SQL Query - Should be easy fix???

    Good job, the scripts do explain what is happening

    😎

    The table dbo.MMA_KPIVAR_DAT can have many instances of the same VARIABLE_ID, CLIENT_ID and SITE_ID. The table dbo.MMA_KPIVAR_MST can have many instances of...

Viewing 15 posts - 6,676 through 6,690 (of 8,755 total)