• ksharpe (10/22/2012)


    Great, thanks. I`ll figure it out as soon as possible.

    kim

    I think this is what you mean by 2 of the tables. The other table(s) is still pretty unclear what is going on there.

    create table #contact

    (

    AccountNo int,

    ContactName varchar(25)

    )

    insert #contact

    select 1234, 'sam' union all

    select 2345, 'geoffrey' union all

    select 2234, 'daniel' union all

    select 5513, 'julia' union all

    select 2115, 'abbey'

    create table #Courses

    (

    Code varchar(25),

    StartDate datetime

    )

    insert #Courses

    select 'TRG1901', '10/01/2009' union all

    select 'TRG1902', '10/08/2009' union all

    select 'TRG1903', '11/14/2009' union all

    select 'TRG1904', '12/10/2009' union all

    select 'TRG2001', '02/12/2010' union all

    select 'TRG2002', '04/21/2010' union all

    select 'TRG2003', '05/06/2010' union all

    select 'TRG2155', '01/01/2010' union all

    select 'TRG2156', '01/01/2010' union all

    select 'TRG2157', '01/01/2010' union all

    select 'TRG2158', '01/01/2010' union all

    select 'TRG2160', '01/01/2010' union all

    select 'TRG2161', '01/01/2010' union all

    select 'TRG2184', '01/01/2011' union all

    select 'TRG2201', '01/01/2012' union all

    select 'TRG2202', '01/01/2012' union all

    select 'TRG2318', '02/09/2008'

    select * from #contact

    select * from #Courses

    drop table #contact

    drop table #Courses

    _______________________________________________________________

    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/