sql Query pls...

  • Hi Friends,

    My table data is like this with 3 columns

    slNo Name Description

    00100 xyz passed

    00100 xyz failed

    00200 abc passed

    00200 abc passed

    00300 def passed

    00300 def failed

    00400 ghi passed

    00400 ghi passed

    My result should be like this.

    slNo Name Description

    00100 xyz passed

    00100 xyz failed

    00300 def passed

    00300 def failed

    If the description column having two passed or two failed for a slno i have to eliminate the entire rows. The result should contain only one passed and one failed for a particular Slno.

    Thanks in advance

    Ramaa

  • SELECT slNo, Name, Description

    FROM dbo.MyTable

    GROUP BY slNo, Name, Description

    HAVING COUNT(*) = 1

    _____________
    Code for TallyGenerator

  • Thank You Sergiy

    Ramaa

  • Hi Sergiy,

    Just now i tried the query. In my case the description column is like this.

    Passed on 02 Mar 2007

    Passed on 02 Mar 2007

    Failed on 02 Mar 2007

    Failed on 02 Mar 2007

    Whether the slno haveing two passed or two failed in description column i have to avoid the rows. Can i use patindex or charindex here?

    Thank you for your response

    Ramaa

  • Yes, you can.

    If you don't plan to have more than couple of hundreds records in this table.

    You you expect the tabe to grow you need to fix table design and that thing which records events into this table.

    _____________
    Code for TallyGenerator

  • Or just use

    LEFT(ColName,6)

    cause fortunately FAILED and PASSED are the same length.

  • Thank You Sergey and Antares686 for your valuable help sorry for late reply.

    Ramaa

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply