how to get odd data using SQL query

  • i Need to get odd data based on ContactID

    table contains more than 10000 records

    table has 9 columns

    FirstName

    MiddleName

    LastName

    Address1

    Address2

    City

    State

    Country

    ContactId

  • What according to you is odd data? provide sample data, sample table structure as CREATE TABLE script and most importantly, your expected output..

  • Please find the table structure as below

    CREATE TABLE Contact

    (

    FirstName varchar(100),

    MiddleName varchar(100),

    LastName varchar(100),

    ContactId int,

    CONSTRAINT pk_Contact_pid PRIMARY KEY(ContactID)

    )

  • Hi,

    Please provide sample data.

  • this is not enuf.. We need sample data and expected output.. and your business process to arrive at the expected output..

  • Assuming by "odd data" you mean "rows where the value of contactid is an odd number" then something like

    select ...

    where contactid % 2 = 1

    Should do the trick. This will however always result in a table scan - but as it likely that you will return 50% of the rows from the table that is probably to be expected.

    Mike

  • I got it solved thanks a lot guys

  • Praveen, Did you use Mike's solution? Is that what you were looiking for?

    _____________________________________________
    One ounce of practice is more important than tonnes of dreams

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

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