• Brad Marsh (3/7/2013)


    Ok was able to get this done now:

    Here is the table structures

    CREATE TABLE [dbo].[HMD](

    [WeekNum] [float] NULL,

    [MonthName] [nvarchar](255) NULL,

    [Response1_Num] [float] NULL,

    [Response2_Num] [float] NULL,

    [Response3_Num] [float] NULL,

    [Response4_Num] [float] NULL,

    [Customer Id] [nvarchar](255) NULL,

    [Email_Queue_Name] [nvarchar](255) NULL,

    [Session Id] [nvarchar](255) NULL,

    [Time_stamp] [float] NULL,

    [CaseID] [nvarchar](255) NULL,

    [Response] [nvarchar](255) NULL,

    [Response1] [nvarchar](255) NULL,

    [Response2] [nvarchar](255) NULL,

    [Response3] [nvarchar](255) NULL,

    [Response4] [nvarchar](255) NULL,

    [comments] [nvarchar](255) NULL,

    [Language] [nvarchar](255) NULL,

    [resolver] [nvarchar](255) NULL,

    [Product] [nvarchar](255) NULL,

    [Agent_TSCS] [nvarchar](255) NULL,

    [SITE] [nvarchar](255) NULL,

    [YYYY_MM] [nvarchar](255) NULL,

    [YYYY_WK] [nvarchar](255) NULL,

    [CS_Queue] [nvarchar](255) NULL,

    [EN_JP] [nvarchar](255) NULL,

    [No_Queue] [nvarchar](255) NULL,

    [Product_Other] [nvarchar](255) NULL

    ) ON [PRIMARY]

    the other tables structure:

    CREATE TABLE [dbo].[Correspondences_All](

    [UserLogin] [varchar](max) NULL,

    [comm_id] [bigint] NULL,

    [CaseID] [int] NULL,

    [Creation_Date] [datetime] NULL,

    [Supervisor] [varchar](max) NULL,

    [YearWeek] [int] NULL

    ) ON [PRIMARY]

    here is the tSQL used to pull the data I need:

    SELECT top 50 ca.Caseid,[weeknum],[monthName], Response1_Num , Response2_Num, Response3_Num, Response4_Num, comments,[userlogin], [supervisor]

    FROM HMD hm

    join Correspondences_All ca on hm.[caseid]=ca.caseid

    where [comments] not in ('null','')

    I have attached an XLS, this shows the output of the query there are 2 sheets (sanatised of course)

    1. What I am getting

    2. what I hope to get out of the query

    As you can see with the second set of results, its filtered out the duplicate comments that are the same, unless the 'userlogin' is different.

    I hope this is what you are after, if I am still missing something please let me know I will do my best to get it up here.

    Now, if you will take your sample data from the Excel spreadsheet and create a series of INSERT INTO statements to load your tables, I would be willing to work on this some more.