merging two rows

  • Hello,

    I have a column patID with some values( with some condition 1), patID with some columns(with some condition 2).How can I merge all the values into a single patID column? My query is like this:

    select patID from table1 where isnumeric(patID)=o

    select patID from table1 where isnumeric(patID)=1

    I want a single patID column by joining these two select statements.

  • Please post a script to create the table, some test data and the expected results. I can't figure out what you want based on what you posted.

    Todd Fifield

  • ramanamreddy (12/7/2011)


    Hello,

    I have a column patID with some values( with some condition 1), patID with some columns(with some condition 2).How can I merge all the values into a single patID column? My query is like this:

    select patID from table1 where isnumeric(patID)=o

    select patID from table1 where isnumeric(patID)=1

    I want a single patID column by joining these two select statements.

    select patID from table1 where isnumeric(patID) in (1,0)

    ______________________________________________________________________________
    How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.

  • toddasd (12/7/2011)


    ramanamreddy (12/7/2011)


    Hello,

    I have a column patID with some values( with some condition 1), patID with some columns(with some condition 2).How can I merge all the values into a single patID column? My query is like this:

    select patID from table1 where isnumeric(patID)=o

    select patID from table1 where isnumeric(patID)=1

    I want a single patID column by joining these two select statements.

    select patID from table1 where isnumeric(patID) in (1,0)

    Or the even simpler version...

    select patID from table1

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • ramanamreddy (12/7/2011)


    Hello,

    I have a column patID with some values( with some condition 1), patID with some columns(with some condition 2).How can I merge all the values into a single patID column? My query is like this:

    select patID from table1 where isnumeric(patID)=o

    select patID from table1 where isnumeric(patID)=1

    I want a single patID column by joining these two select statements.

    You do understand that by asking ISNUMERIC you will only get 0 or 1? Therefore, the 2 statements you are using are not needed; i.e. together they return ALL results from the table. It is like saying "all of the people who agree with me, come with me. all of the people who disagree with me, come with me." Nobody is left behind!

    Jared

    Jared
    CE - Microsoft

  • Sean Lange (12/7/2011)


    toddasd (12/7/2011)


    ramanamreddy (12/7/2011)


    Hello,

    I have a column patID with some values( with some condition 1), patID with some columns(with some condition 2).How can I merge all the values into a single patID column? My query is like this:

    select patID from table1 where isnumeric(patID)=o

    select patID from table1 where isnumeric(patID)=1

    I want a single patID column by joining these two select statements.

    select patID from table1 where isnumeric(patID) in (1,0)

    Or the even simpler version...

    select patID from table1

    /smackshead :pinch:

    I couldn't see past

    select patID from table1 where patID in (1,0)

    ______________________________________________________________________________
    How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.

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

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