How to add multiple columns from different tables into one column of new table

  • Hello Florian Reischl

    Thank you so much for your efforts to show me how to post my question, so I can get better help.

    I am new to SQL, so please help me

    Again, Thank you so much

  • josephptran2002(4/2/2009)


    would you please tell me how to create a table with the sample data in table?

    He already has.

    Florian Reischl (4/2/2009)


    Better way for this:

    CREATE TABLE #BO

    (

    BODDS VARCHAR(10),

    BOCLEARED INT,

    BOCLEAREDDATE DATETIME

    )

    INSERT INTO #BO

    SELECT 'BO', 3, '1/1/2009'

    UNION SELECT 'BO', 1, '1/2/2009'

    UNION SELECT 'BO', 5, '1/3/2009'

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hello there,

    Would you please tell me why I could not create a table with sample data in the table?

    Thank you

    Joseph

  • Would you please tell me why I could not create a table with sample data in the table?

    I don't really understand you. Open your Management Studio, type a valid CREATE TABLE statement, add some lines to add for sample data and post it. (enclosed with [ code ] and [ /code ])

    Greets

    Flo

  • Hello there,

    Before I type the codes in there, do i have to click on any IFCode shortcuts?

    Thank you

  • Create Table #WeeklyActualClearedCasewithNoReturns

    (

    SSN INT, DDS Varchar(3), DECLEAREDDATE Datetime, SOMATICMCCLEAREDDATE Datetime,PSYCMCCLEAREDDATE DATETIME, DESECONDCLEAREDDATE DATETIME,SOMATICMCSECONDCLEAREDDATE DATETIME, PSYCMCSECONDCLEAREDDATE DATETIME

    )

    INSERT INTO #WeeklyActualClearedCasewithNoReturns

    Select '000112222', 'CT', '1/1/2009', ' ', ' ', ' ', ' ', ' ' Union Select '111335555', 'ME', ' ', ' ', '1/4/2009', ' ', ' ', ' ' Union Select '666223333', 'CT', ' ', '1/6/2009', ' ', ' ', ' ', ' ' Union Select '999228888', 'RI', ' ', ' ', '1/11/2009', ' ', ' ', ' '

  • ???

    Either type:

    [ code ]

    HERE ENTER YOUR SQL

    [ /code ]

    (both code tags without the spaces)

    or click the "[ code ][ /code]" link, set the cursor into the middle of the ][ and copy your SQL into.

    If you are not sure if you did right use the "Preview" button.

    Greets

    Flo

  • FWIW:

    (Sorry - couldn't work out how to format it nicely...)

    [font="System"]

    SELECT REPLACE(RTRIM(ISNULL(BODDS+' ','')+ISNULL(CTDDS+' ','')+ISNULL(NHDDS,'')),' ',',') AS DDS

    ,ISNULL(BOCLEARED,0)+ISNULL(CTCLEARED,0)+ISNULL(NHCLEARED,0) AS TotalCleared

    ,COALESCE(BOCLEAREDDATE,CTCLEAREDDATE,NHCLEAREDDATE) AS ClearedDate FROM BO

    FULL OUTER JOIN CT ON BOCLEAREDDATE=CTCLEAREDDATE

    FULL OUTER JOIN NH ON BOCLEAREDDATE=NHCLEAREDDATE OR CTCLEAREDDATE=NHCLEAREDDATE

    ORDER BY 3

    [/font]

  • Hello Schnurdle

    How are you doing? Thank you so much for your efforts to help me out and I already solved this issue. Again, thank you so so much

    Very Respectful

    Joseph Tran

  • Hello Florian Reischl,

    How are you doing? Thank you so much for your helps, I wish there are more people like you to help new developer at their beginning stage of how to program SQL. May god bless you and help other new developer out there. Some people in here, they are here to show off and intimidate new developer. Not try to help them out and misguide others to different issues.

    Very Respectful

    Joseph

  • josephptran2002 (4/3/2009)


    Some people in here, they are here to show off and intimidate new developer. Not try to help them out and misguide others to different issues.

    Want to name those people you feel are showing off?

    We're trying to help you. If someone suggest a different option, it's because they think it may be a better way than what you're currently doing. None of the regular posters post to show off their skills

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hello Gila,

    How are you bro? I am not talking about you, because you tried many different ways to help me. So, there are no words than saying "Thank you so much".

    You are very kind expert to show new developer to a right path in order to solve my issue.

    Again, Thank you

    Joseph Tran

Viewing 12 posts - 16 through 26 (of 26 total)

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