Single Row out of multiple Rows

entID sourceAID sourceA
100 123123 DFW
100 34343 NYC
100 343434 MIA
100 42222 SA
200 123 DFW
200 343 NYC
200 422 SA
The example above is just a small subset of over 1000 records.
Is there a way I can get the data returned as such? The column positions do not matter, I just want the entID to always be in the same row.
100 123123 DFW 34343 NYC 343434 MIA 42222 SA
200 123 DFW 343 NYC 422 SA
Thanks for any ideas!

>
I had a table1 ,in which there is a column as address ,having the data like 'address1|address2|address3|city|state|postal|country' (the data with pipe delimiter).
Now,i have to insert this column into multiple columns in another table2 using sql query .So,i want to split the one column based upon the
delimiter and insert the data into multiple fields in another table.Basically, you have a pipe delimited file that you wish to put into a table.
This is what External Tables were made for.
First: create or replace directory WORKDIR as '/tmp';
CREATE TABLE Address_ext       <===== I find adding ext is good for one's sanity
Address1  VARCHAR2(50),            <========== in ext tables, datatype has to be VARCHAR2 because you don't know what's coming in.
Address2  VARCHAR2(50),
Address3  VARCHAR2(15),
City            VARCHAR2(30),
Postal        VARCHAR2(10),
Country     VARCHAR2(25),
ORGANIZATION EXTERNAL
  type oracle_loader
  default directory WORKDIR
  access parameters
    records delimited by newline
    fields terminated by '|'
    missing field     values are null
    badfile 'tester.bad'
    logfile 'tester.log'
  location ('my_datafile.dat')
reject limit unlimited;Then you do something like this
INSERT INTO Address_Tbl
SELECT * FROM Address_ext
COMMIT;You might want to have a staging table or something if you have to check if Postal Codes are
valid, the City is in a City table that you might have or whatever...
Example of what I did Sysstat is my Oracle normal table, Sysstat_ext is my external table. I
was able to do the processing directly in SQL since it was a fairly simple conversion.
INSERT INTO Sysstat
SELECT ROUND(TO_DATE  (Sysstat_ext.M_Time, 'DD-MM HH24:MI:SS'), 'MI') AS "Measurement Time",
       ROUND(TO_NUMBER(Sysstat_ext.Usr_pct),    0) AS "% Usr",
       ROUND(TO_NUMBER(Sysstat_ext.Sys_pct),    0) AS "% System",
       ROUND(TO_NUMBER(Sysstat_ext.Idle_pct),   0) AS "% Idle",
       ROUND(TO_NUMBER(Sysstat_ext.Wait_pct),   0) AS "% Wait",
       ROUND(TO_NUMBER(Sysstat_ext.HW_intpt),   0) AS "HW interrupts",
       ROUND(TO_NUMBER(Sysstat_ext.SW_intpt),   0) AS "SW interrupts",
       ROUND(TO_NUMBER(Sysstat_ext.Bytes_r),    0) AS "Bytes Read",
       ROUND(TO_NUMBER(Sysstat_ext.Bytes_w),    0) AS "Bytes Written",
       ROUND(TO_NUMBER(Sysstat_ext.Pages_in),   0) AS "Pages in",
       ROUnD(TO_NUMBER(Sysstat_ext.Pages_out),  0) AS "Pages out",
       ROUND(TO_NUMBER(Sysstat_ext.Bytes_rec),  0) AS "Bytes received",
       ROUND(TO_NUMBER(Sysstat_ext.Bytes_sent), 0) AS "Bytes sent",
       ROUND(TO_NUMBER(Sysstat_ext.Interrupts), 0) AS "Interrupts",
       ROUND(TO_NUMBER(Sysstat_ext.Cont_sw),    0) AS "Context switches"
FROM Sysstat_ext;
COMMIT;HTH,
Paul...

Similar Messages

  • Auto archive log deletion from single location out of multiple locations.

    Hi,
    I am running database on 11r1 version.
    I have set two archive log locations. now i want archive logs to be deleted through RMAN from only one location the other location shouldn't be affected. what are the specific parameters to be set. Is there any specific command for this please advise.
    Thanks in advance.

    If you see Hemant's reply in the below link, he had shown how to delete archives from 1 location.
    RMAN backup with 2 archive log locations

  • Updating single row by multiple users at the same time

    Hi,
    I have been asked to develop an application where a single row from a table will be accessed by multiple users. Even multiple users can try to update the same row at the same time. So, to provide a solution of this problem should it be the best way to lock that particular row when user requesting to update it and after completion of commit the lock will be released. In the same time if some other user request to update the same row then it will be in the wait condition.
    Please provide suggestion that is it the best way to handle the situation or not. If it is then can you also please provide an example (with sample code) of it.
    Regards,
    Koushik

    It depends entirely on how the system was built.
    You could relatively easily build an application that does something like
    - Select a row with as last_updated_date column
    - Update the row specifying the last_updated_date you had selected in your WHERE clause
    - If the update updates 1 row, it was successful, otherwise inform the user that the row was already updated.
    In this case, the second user would get an error indicating that the seat had already been purchased.
    You could also relatively easily do a SELECT FOR UPDATE to prevent users from ever getting an error between the time they select a seat and the time they finish their transaction. Of course, if the user wanders away from the computer, or inadvertently ends up locking dozens of rows, this tends to rather problematic in practice. You may find that when the train pulls out of the station, someone that never ended up buying a ticket has locked a dozen rows so you lost a dozen sales. If you have a call center where operators are reserving seats for people on the phone, you may decide that explicit locking is more appropriate because you're confident that the operators aren't going to leave tickets locked for long periods of time and the cost of having the customer walked through the seat selection process multiple times would be higher than the cost of having rows locked longer than they need to be.
    Justin

  • Merging Multiple Rows into a single Row

    I've read a number of posts with no real good answers or answers that might be good for tables with 3 columns of data. I have a table with 33 columns that will all need to be combined. A little history. Apparently in production the Primary Key Constraint
    was dropped which allowed some duplicate data into the table. Now they want me to squish the records together to fix it.
    Sorry I couldn't include the screen shot of the data, MSDN says my account isn't verified...
    My requirements when I'm putting them together, CERElibilityID is a unique column. This is a sticky problem because in the related tables it is only one of the parent records gets child records related to it.
     I just want to keep the one that has the child records in CERPrepActivity table. If there are no child records then the rule will be like all the other records with data. 
    If a  field is null and another record has data we take the record that has data.
    If multiple records have data we take the record that has the highest "ModifiedOn" timestamp column value.
    I feel like I'm asking a lot, but I'm in a bit of a bind and I've spent the morning Googling and have come up with nothing 
    Thank  you for any help the community can provide and the more specific you can be the better. I'm not a DBA or SQL guru by any stretch so I'm way out of my element.
    Thanks

    Using the systables, you can get information about your table. I put these together:
    SELECT '
    LEFT OUTER JOIN #CEREligibility ['+c.name+']
    ON s.caseID = ['+c.name+'].caseID
    AND s.modifiedOn = ['+c.name+'].modifiedOn
    AND ['+c.name+'].['+c.name+'] = (SELECT TOP 1 ['+c.name+'] FROM #CEREligibility WHERE caseID = s.caseID AND ['+c.name+'] IS NOT NULL ORDER BY ModifiedOn)
    AND ['+c.name+'].['+c.name+'] IS NOT NULL'
    FROM tempdb.sys.objects o
    INNER JOIN tempdb.sys.columns c
    ON o.object_id = c.object_id
    AND o.name LIKE '#CEREligibility%'
    SELECT '['+c.name+'].['+c.name+'] AS ['+c.name+'], '
    FROM tempdb.sys.objects o
    INNER JOIN tempdb.sys.columns c
    ON o.object_id = c.object_id
    AND o.name LIKE '#CEREligibility%'
    On my test system I created your table as a temp table named #CEREligibility.
    The first of these two queries generates LEFT OUT JOIN SQL for a self join. Because we're using the columns systable, a LOJ for each column is generated.
    The second, produces a select list.
    Putting the two together like so, and adding a FROM and GROUP BY gives us:
    SELECT
    MAX([CEREligibilityId].[CEREligibilityId]) AS [CEREligibilityId], s.[CaseId], MAX([M2Eligibility].[M2Eligibility]) AS [M2Eligibility], MAX([CDREligibility].[CDREligibility]) AS [CDREligibility], MAX([M2Comments].[M2Comments]) AS [M2Comments], MAX([M2CommentsRtf].[M2CommentsRtf]) AS [M2CommentsRtf], MAX([CDRComments].[CDRComments]) AS [CDRComments], MAX([CDRCommentsRtf].[CDRCommentsRtf]) AS [CDRCommentsRtf], MAX([RIAWA].[RIAWA]) AS [RIAWA], MAX([RIAWADate].[RIAWADate]) AS [RIAWADate], MAX([EducationAndTraining].[EducationAndTraining]) AS [EducationAndTraining], MAX([EducationAndTrainingDate].[EducationAndTrainingDate]) AS [EducationAndTrainingDate], MAX([Internship].[Internship]) AS [Internship], MAX([InternshipDate].[InternshipDate]) AS [InternshipDate], MAX([Apprenticeship].[Apprenticeship]) AS [Apprenticeship], MAX([ApprenticeshipDate].[ApprenticeshipDate]) AS [ApprenticeshipDate], MAX([Entrepreneurship].[Entrepreneurship]) AS [Entrepreneurship], MAX([EntrepreneurshipDate].[EntrepreneurshipDate]) AS [EntrepreneurshipDate], MAX([EmploymentPrep].[EmploymentPrep]) AS [EmploymentPrep], MAX([EmploymentPrepDate].[EmploymentPrepDate]) AS [EmploymentPrepDate], MAX([OTPrep].[OTPrep]) AS [OTPrep], MAX([OTPrepDate].[OTPrepDate]) AS [OTPrepDate], MAX([ExitInterview].[ExitInterview]) AS [ExitInterview], MAX([ExitInterviewDate].[ExitInterviewDate]) AS [ExitInterviewDate], MAX([CreatedOn].[CreatedOn]) AS [CreatedOn], MAX([CreatedBy].[CreatedBy]) AS [CreatedBy], MAX([ModifiedOn].[ModifiedOn]) AS [ModifiedOn], MAX([ModifiedBy].[ModifiedBy]) AS [ModifiedBy], MAX([BCPermInEligibility].[BCPermInEligibility]) AS [BCPermInEligibility], MAX([CCPermInEligibility].[CCPermInEligibility]) AS [CCPermInEligibility], MAX([M2EligibilityDate].[M2EligibilityDate]) AS [M2EligibilityDate], MAX([CDREligibilityDate].[CDREligibilityDate]) AS [CDREligibilityDate], MAX([ExitSeparationCode].[ExitSeparationCode]) AS [ExitSeparationCode], MAX([ExitSeparationSubCode].[ExitSeparationSubCode]) AS [ExitSeparationSubCode]
    FROM #CEREligibility s
    LEFT OUTER JOIN #CEREligibility [CEREligibilityId]
    ON s.caseID = [CEREligibilityId].caseID
    AND s.modifiedOn = [CEREligibilityId].modifiedOn
    AND [CEREligibilityId].[CEREligibilityId] = (SELECT TOP 1 [CEREligibilityId] FROM #CEREligibility WHERE caseID = s.caseID AND [CEREligibilityId] IS NOT NULL ORDER BY ModifiedOn)
    AND [CEREligibilityId].[CEREligibilityId] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [CaseId]
    ON s.caseID = [CaseId].caseID
    AND s.modifiedOn = [CaseId].modifiedOn
    AND [CaseId].[CaseId] = (SELECT TOP 1 [CaseId] FROM #CEREligibility WHERE caseID = s.caseID AND [CaseId] IS NOT NULL ORDER BY ModifiedOn)
    AND [CaseId].[CaseId] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [M2Eligibility]
    ON s.caseID = [M2Eligibility].caseID
    AND s.modifiedOn = [M2Eligibility].modifiedOn
    AND [M2Eligibility].[M2Eligibility] = (SELECT TOP 1 [M2Eligibility] FROM #CEREligibility WHERE caseID = s.caseID AND [M2Eligibility] IS NOT NULL ORDER BY ModifiedOn)
    AND [M2Eligibility].[M2Eligibility] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [CDREligibility]
    ON s.caseID = [CDREligibility].caseID
    AND s.modifiedOn = [CDREligibility].modifiedOn
    AND [CDREligibility].[CDREligibility] = (SELECT TOP 1 [CDREligibility] FROM #CEREligibility WHERE caseID = s.caseID AND [CDREligibility] IS NOT NULL ORDER BY ModifiedOn)
    AND [CDREligibility].[CDREligibility] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [M2Comments]
    ON s.caseID = [M2Comments].caseID
    AND s.modifiedOn = [M2Comments].modifiedOn
    AND [M2Comments].[M2Comments] = (SELECT TOP 1 [M2Comments] FROM #CEREligibility WHERE caseID = s.caseID AND [M2Comments] IS NOT NULL ORDER BY ModifiedOn)
    AND [M2Comments].[M2Comments] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [M2CommentsRtf]
    ON s.caseID = [M2CommentsRtf].caseID
    AND s.modifiedOn = [M2CommentsRtf].modifiedOn
    AND [M2CommentsRtf].[M2CommentsRtf] = (SELECT TOP 1 [M2CommentsRtf] FROM #CEREligibility WHERE caseID = s.caseID AND [M2CommentsRtf] IS NOT NULL ORDER BY ModifiedOn)
    AND [M2CommentsRtf].[M2CommentsRtf] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [CDRComments]
    ON s.caseID = [CDRComments].caseID
    AND s.modifiedOn = [CDRComments].modifiedOn
    AND [CDRComments].[CDRComments] = (SELECT TOP 1 [CDRComments] FROM #CEREligibility WHERE caseID = s.caseID AND [CDRComments] IS NOT NULL ORDER BY ModifiedOn)
    AND [CDRComments].[CDRComments] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [CDRCommentsRtf]
    ON s.caseID = [CDRCommentsRtf].caseID
    AND s.modifiedOn = [CDRCommentsRtf].modifiedOn
    AND [CDRCommentsRtf].[CDRCommentsRtf] = (SELECT TOP 1 [CDRCommentsRtf] FROM #CEREligibility WHERE caseID = s.caseID AND [CDRCommentsRtf] IS NOT NULL ORDER BY ModifiedOn)
    AND [CDRCommentsRtf].[CDRCommentsRtf] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [RIAWA]
    ON s.caseID = [RIAWA].caseID
    AND s.modifiedOn = [RIAWA].modifiedOn
    AND [RIAWA].[RIAWA] = (SELECT TOP 1 [RIAWA] FROM #CEREligibility WHERE caseID = s.caseID AND [RIAWA] IS NOT NULL ORDER BY ModifiedOn)
    AND [RIAWA].[RIAWA] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [RIAWADate]
    ON s.caseID = [RIAWADate].caseID
    AND s.modifiedOn = [RIAWADate].modifiedOn
    AND [RIAWADate].[RIAWADate] = (SELECT TOP 1 [RIAWADate] FROM #CEREligibility WHERE caseID = s.caseID AND [RIAWADate] IS NOT NULL ORDER BY ModifiedOn)
    AND [RIAWADate].[RIAWADate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [EducationAndTraining]
    ON s.caseID = [EducationAndTraining].caseID
    AND s.modifiedOn = [EducationAndTraining].modifiedOn
    AND [EducationAndTraining].[EducationAndTraining] = (SELECT TOP 1 [EducationAndTraining] FROM #CEREligibility WHERE caseID = s.caseID AND [EducationAndTraining] IS NOT NULL ORDER BY ModifiedOn)
    AND [EducationAndTraining].[EducationAndTraining] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [EducationAndTrainingDate]
    ON s.caseID = [EducationAndTrainingDate].caseID
    AND s.modifiedOn = [EducationAndTrainingDate].modifiedOn
    AND [EducationAndTrainingDate].[EducationAndTrainingDate] = (SELECT TOP 1 [EducationAndTrainingDate] FROM #CEREligibility WHERE caseID = s.caseID AND [EducationAndTrainingDate] IS NOT NULL ORDER BY ModifiedOn)
    AND [EducationAndTrainingDate].[EducationAndTrainingDate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [Internship]
    ON s.caseID = [Internship].caseID
    AND s.modifiedOn = [Internship].modifiedOn
    AND [Internship].[Internship] = (SELECT TOP 1 [Internship] FROM #CEREligibility WHERE caseID = s.caseID AND [Internship] IS NOT NULL ORDER BY ModifiedOn)
    AND [Internship].[Internship] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [InternshipDate]
    ON s.caseID = [InternshipDate].caseID
    AND s.modifiedOn = [InternshipDate].modifiedOn
    AND [InternshipDate].[InternshipDate] = (SELECT TOP 1 [InternshipDate] FROM #CEREligibility WHERE caseID = s.caseID AND [InternshipDate] IS NOT NULL ORDER BY ModifiedOn)
    AND [InternshipDate].[InternshipDate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [Apprenticeship]
    ON s.caseID = [Apprenticeship].caseID
    AND s.modifiedOn = [Apprenticeship].modifiedOn
    AND [Apprenticeship].[Apprenticeship] = (SELECT TOP 1 [Apprenticeship] FROM #CEREligibility WHERE caseID = s.caseID AND [Apprenticeship] IS NOT NULL ORDER BY ModifiedOn)
    AND [Apprenticeship].[Apprenticeship] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [ApprenticeshipDate]
    ON s.caseID = [ApprenticeshipDate].caseID
    AND s.modifiedOn = [ApprenticeshipDate].modifiedOn
    AND [ApprenticeshipDate].[ApprenticeshipDate] = (SELECT TOP 1 [ApprenticeshipDate] FROM #CEREligibility WHERE caseID = s.caseID AND [ApprenticeshipDate] IS NOT NULL ORDER BY ModifiedOn)
    AND [ApprenticeshipDate].[ApprenticeshipDate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [Entrepreneurship]
    ON s.caseID = [Entrepreneurship].caseID
    AND s.modifiedOn = [Entrepreneurship].modifiedOn
    AND [Entrepreneurship].[Entrepreneurship] = (SELECT TOP 1 [Entrepreneurship] FROM #CEREligibility WHERE caseID = s.caseID AND [Entrepreneurship] IS NOT NULL ORDER BY ModifiedOn)
    AND [Entrepreneurship].[Entrepreneurship] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [EntrepreneurshipDate]
    ON s.caseID = [EntrepreneurshipDate].caseID
    AND s.modifiedOn = [EntrepreneurshipDate].modifiedOn
    AND [EntrepreneurshipDate].[EntrepreneurshipDate] = (SELECT TOP 1 [EntrepreneurshipDate] FROM #CEREligibility WHERE caseID = s.caseID AND [EntrepreneurshipDate] IS NOT NULL ORDER BY ModifiedOn)
    AND [EntrepreneurshipDate].[EntrepreneurshipDate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [EmploymentPrep]
    ON s.caseID = [EmploymentPrep].caseID
    AND s.modifiedOn = [EmploymentPrep].modifiedOn
    AND [EmploymentPrep].[EmploymentPrep] = (SELECT TOP 1 [EmploymentPrep] FROM #CEREligibility WHERE caseID = s.caseID AND [EmploymentPrep] IS NOT NULL ORDER BY ModifiedOn)
    AND [EmploymentPrep].[EmploymentPrep] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [EmploymentPrepDate]
    ON s.caseID = [EmploymentPrepDate].caseID
    AND s.modifiedOn = [EmploymentPrepDate].modifiedOn
    AND [EmploymentPrepDate].[EmploymentPrepDate] = (SELECT TOP 1 [EmploymentPrepDate] FROM #CEREligibility WHERE caseID = s.caseID AND [EmploymentPrepDate] IS NOT NULL ORDER BY ModifiedOn)
    AND [EmploymentPrepDate].[EmploymentPrepDate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [OTPrep]
    ON s.caseID = [OTPrep].caseID
    AND s.modifiedOn = [OTPrep].modifiedOn
    AND [OTPrep].[OTPrep] = (SELECT TOP 1 [OTPrep] FROM #CEREligibility WHERE caseID = s.caseID AND [OTPrep] IS NOT NULL ORDER BY ModifiedOn)
    AND [OTPrep].[OTPrep] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [OTPrepDate]
    ON s.caseID = [OTPrepDate].caseID
    AND s.modifiedOn = [OTPrepDate].modifiedOn
    AND [OTPrepDate].[OTPrepDate] = (SELECT TOP 1 [OTPrepDate] FROM #CEREligibility WHERE caseID = s.caseID AND [OTPrepDate] IS NOT NULL ORDER BY ModifiedOn)
    AND [OTPrepDate].[OTPrepDate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [ExitInterview]
    ON s.caseID = [ExitInterview].caseID
    AND s.modifiedOn = [ExitInterview].modifiedOn
    AND [ExitInterview].[ExitInterview] = (SELECT TOP 1 [ExitInterview] FROM #CEREligibility WHERE caseID = s.caseID AND [ExitInterview] IS NOT NULL ORDER BY ModifiedOn)
    AND [ExitInterview].[ExitInterview] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [ExitInterviewDate]
    ON s.caseID = [ExitInterviewDate].caseID
    AND s.modifiedOn = [ExitInterviewDate].modifiedOn
    AND [ExitInterviewDate].[ExitInterviewDate] = (SELECT TOP 1 [ExitInterviewDate] FROM #CEREligibility WHERE caseID = s.caseID AND [ExitInterviewDate] IS NOT NULL ORDER BY ModifiedOn)
    AND [ExitInterviewDate].[ExitInterviewDate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [CreatedOn]
    ON s.caseID = [CreatedOn].caseID
    AND s.modifiedOn = [CreatedOn].modifiedOn
    AND [CreatedOn].[CreatedOn] = (SELECT TOP 1 [CreatedOn] FROM #CEREligibility WHERE caseID = s.caseID AND [CreatedOn] IS NOT NULL ORDER BY ModifiedOn)
    AND [CreatedOn].[CreatedOn] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [CreatedBy]
    ON s.caseID = [CreatedBy].caseID
    AND s.modifiedOn = [CreatedBy].modifiedOn
    AND [CreatedBy].[CreatedBy] = (SELECT TOP 1 [CreatedBy] FROM #CEREligibility WHERE caseID = s.caseID AND [CreatedBy] IS NOT NULL ORDER BY ModifiedOn)
    AND [CreatedBy].[CreatedBy] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [ModifiedOn]
    ON s.caseID = [ModifiedOn].caseID
    AND s.modifiedOn = [ModifiedOn].modifiedOn
    AND [ModifiedOn].[ModifiedOn] = (SELECT TOP 1 [ModifiedOn] FROM #CEREligibility WHERE caseID = s.caseID AND [ModifiedOn] IS NOT NULL ORDER BY ModifiedOn)
    AND [ModifiedOn].[ModifiedOn] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [ModifiedBy]
    ON s.caseID = [ModifiedBy].caseID
    AND s.modifiedOn = [ModifiedBy].modifiedOn
    AND [ModifiedBy].[ModifiedBy] = (SELECT TOP 1 [ModifiedBy] FROM #CEREligibility WHERE caseID = s.caseID AND [ModifiedBy] IS NOT NULL ORDER BY ModifiedOn)
    AND [ModifiedBy].[ModifiedBy] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [BCPermInEligibility]
    ON s.caseID = [BCPermInEligibility].caseID
    AND s.modifiedOn = [BCPermInEligibility].modifiedOn
    AND [BCPermInEligibility].[BCPermInEligibility] = (SELECT TOP 1 [BCPermInEligibility] FROM #CEREligibility WHERE caseID = s.caseID AND [BCPermInEligibility] IS NOT NULL ORDER BY ModifiedOn)
    AND [BCPermInEligibility].[BCPermInEligibility] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [CCPermInEligibility]
    ON s.caseID = [CCPermInEligibility].caseID
    AND s.modifiedOn = [CCPermInEligibility].modifiedOn
    AND [CCPermInEligibility].[CCPermInEligibility] = (SELECT TOP 1 [CCPermInEligibility] FROM #CEREligibility WHERE caseID = s.caseID AND [CCPermInEligibility] IS NOT NULL ORDER BY ModifiedOn)
    AND [CCPermInEligibility].[CCPermInEligibility] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [M2EligibilityDate]
    ON s.caseID = [M2EligibilityDate].caseID
    AND s.modifiedOn = [M2EligibilityDate].modifiedOn
    AND [M2EligibilityDate].[M2EligibilityDate] = (SELECT TOP 1 [M2EligibilityDate] FROM #CEREligibility WHERE caseID = s.caseID AND [M2EligibilityDate] IS NOT NULL ORDER BY ModifiedOn)
    AND [M2EligibilityDate].[M2EligibilityDate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [CDREligibilityDate]
    ON s.caseID = [CDREligibilityDate].caseID
    AND s.modifiedOn = [CDREligibilityDate].modifiedOn
    AND [CDREligibilityDate].[CDREligibilityDate] = (SELECT TOP 1 [CDREligibilityDate] FROM #CEREligibility WHERE caseID = s.caseID AND [CDREligibilityDate] IS NOT NULL ORDER BY ModifiedOn)
    AND [CDREligibilityDate].[CDREligibilityDate] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [ExitSeparationCode]
    ON s.caseID = [ExitSeparationCode].caseID
    AND s.modifiedOn = [ExitSeparationCode].modifiedOn
    AND [ExitSeparationCode].[ExitSeparationCode] = (SELECT TOP 1 [ExitSeparationCode] FROM #CEREligibility WHERE caseID = s.caseID AND [ExitSeparationCode] IS NOT NULL ORDER BY ModifiedOn)
    AND [ExitSeparationCode].[ExitSeparationCode] IS NOT NULL
    LEFT OUTER JOIN #CEREligibility [ExitSeparationSubCode]
    ON s.caseID = [ExitSeparationSubCode].caseID
    AND s.modifiedOn = [ExitSeparationSubCode].modifiedOn
    AND [ExitSeparationSubCode].[ExitSeparationSubCode] = (SELECT TOP 1 [ExitSeparationSubCode] FROM #CEREligibility WHERE caseID = s.caseID AND [ExitSeparationSubCode] IS NOT NULL ORDER BY ModifiedOn)
    AND [ExitSeparationSubCode].[ExitSeparationSubCode] IS NOT NULL
    GROUP BY s.caseID
    When I ran this against your test data, It produced a single row for each of the two case ID's.
    To keep performance in line, I also created a covering index on the temp table:
    CREATE INDEX idx_caseID_ModifiedOn ON #CEREligibility (caseID, modifiedOn) INCLUDE ([CEREligibilityId], [M2Eligibility], [CDREligibility], [M2Comments], [M2CommentsRtf], [CDRComments], [CDRCommentsRtf], [RIAWA], [RIAWADate], [EducationAndTraining], [EducationAndTrainingDate], [Internship], [InternshipDate], [Apprenticeship], [ApprenticeshipDate], [Entrepreneurship], [EntrepreneurshipDate], [EmploymentPrep], [EmploymentPrepDate], [OTPrep], [OTPrepDate], [ExitInterview], [ExitInterviewDate], [CreatedOn], [CreatedBy], [ModifiedBy], [BCPermInEligibility], [CCPermInEligibility], [M2EligibilityDate], [CDREligibilityDate], [ExitSeparationCode], [ExitSeparationSubCode])
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • Oracle query - Merging multiple rows into a single row output

    Hi All,
    I have to have a multiple row output to be converted into a single row output.My current output looks as follows:
    ID YR INC_CODE OFFN SCHOOLNO
    8006 2002 00175 SC03 12
    8006 2002 00175 DC06 12
    8006 2002 00175 DC03 12
    8006 2002 00175 DC02 12
    ID,INCIDENT CODE,OFFENSE are all Primary keys
    So I need the output as follows:(IN ONE ROW)
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 SCHOOLNO
    8006 2002 00175 SC03 DC06 DC03 DC02 12
    Can you help me on this since have been spinning the wheel and this has to be a query since will have couple of tables join to produce a materialized view.
    Thanks in advance

    Hi Nigel,
    Thanks for the reply I tested out the portion having the decode and I get the output as follows:
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
    8982 2002 2175 DOC01 -----------------------
    8982 2002 2175 DOC02-------------------
    8982 2002 2175 DOC03------------
    8982 2002 2175 DOC06-------
    8982 2002 2175 SCV03
    There is no value as max for OFFN and each INC_CODE MAY HAVE UP TO A MAX OF 5 OFFN.My query is as follows:
    select distinct STU_STUDENT_ID, INC_BEG_SCH_YR,INC_INCIDENT_CODE
    , decode(rank() over (partition by INC_CODE order by OFFN),1,OFFN,null) as offn1
    , decode(rank() over (partition by INC_CODE order by OFFN),2,OFFN,null) as offn2
    , decode(rank() over (partition by INC_CODE order by OFFN),3,OFFN,null) as offn3
    , decode(rank() over (partition by INC_CODE order by OFFN),4,OFFN,null) as offn4
    , decode(rank() over (partition by INC_CODE order by OFFN),5,OFFN,null) as offn5
    from stu_offn where
    stu_offn.ID = '8982' and stu_offn.INC_CODE = '2175'
    (****Where clause is just given to just check a value)
    So as you know I need to just have all the OFFN in a single row ie as follows:
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
    8982 2002 2175 DOC01 DOC02 DOC03 DOC06 SCV03
    Can you just give me a step by step procedure to go through this and the table in this case is just 'STU_OFFN'
    Thanks for the earlier reply appreciate it!
    ****Sending this again to show the exact way the output is coming

  • Combine multiple rows in single row

    I am new to SQL server and i am trying to combine multiple row in single row but i am not able to do it.Can anyone help me out?
    Input :
    Id |RED |BUY |BSW
    1328 NULL NULL 0.05
    1328 NULL 0.06 NULL
    1328 0.01 NULL NULL
    1328 0.05 NULL NULL
    1329 NULL NULL 0.05
    1329 NULL 0.05 NULL
    1329 0.05 NULL NULL
    Output
    Id |RED |BUY |BSW
    1328 0.01 0.06 0.05
    1328 0.05 NULL NULL
    1329 0.05 0.05 0.05

    Actually I am consolidating above result into text file and sending it to external system.Main aim is to remove NULL values and arrange the data as expected output.
    Also expected output can be
    Id         |RED   
    |BUY    |BSW
    1328        0.05   
    0.06    0.05
    1328        0.01   
    NULL    NULL
    Or
    Id         |RED   
    |BUY    |BSW
    1328        0.01   
    0.06    0.05
    1328        0.05   
    NULL    NULL
    for Id= 1328.

  • Splitting  single row to multiple query result

    Hi All,
    I have a column is a table with data seperated by new like . I need to write a select query which can split this to multiple rows .. can any one help me out .
    please see the xample
    select data_comm from customer where rownum=1
    data_comm
    serial=0
    parallel=1
    comm=1
    a single row contain a field called data_comm which has got data stored seperated by new_line
    I need to write a query which can split data on data_comm and give as multiple rows.
    Thanks in advance

    I think something like this would do the trick.
    Part 1:
    select substr(data_comm, 1, instr(data_comm,chr(10),1)) from customer ;
    Part 2:
    select substr(data_comm,instr(data_comm,chr(10),1)+1,instr(data_comm,chr(10),2)) from customer ;
    Part 3:
    select substr(data_comm,instr(data_comm,chr(10),2)+1,instr(data_comm,chr(10),3)) from customer ;
    Maybe the chr(10) is not the used newline char, but you can figure that one out yourself

  • Multiple rows Converge to Single row and join

    Hi Folks,
    I am facing a tricky challenge to join a table with multiple rows and converge into a single row (based on ID, period) and join with another table to get a single row. Let me explain.
    Table 1: DTL_TABLE (id, period, course, names, title, type)
    1 2010 mat john null null
    1 2010 mat jim null null
    1 2010 cam null officer null
    1 2010 cam null Prof null
    1 2010 phy null null Inclass
    1 2010 phy null null Online
    Join with
    Table 2: ID_TABLE(id, period, Loc, Dept, Code)
    1 2010 nj 101 CC.
    Output format (id, period, course, names, title, type, Loc, Dept, Code)
    result : 1 2010 mat,cam,phy john,jim officer,prof inclass,online nj 101 CC
    I have created all the DDLs and DMLs if that help. Kindly let me know if a Join SQL query is possible.
    Thank you,
    Aj
    CREATE TABLE DTL_TABLE
       ids      VARCHAR2 (10),
       period   VARCHAR2 (10),
       course   VARCHAR2 (10),
       names    VARCHAR2 (10),
       title    VARCHAR2 (10),
       TYPE     VARCHAR2 (10)
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'mat',
                 'jim',
                 NULL,
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'mat',
                 'john',
                 NULL,
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'mat',
                 'kale',
                 NULL,
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'cam',
                 NULL,
                 'officer',
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'cam',
                 NULL,
                 'prof',
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'phy',
                 NULL,
                 NULL,
                 'inclass');
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'phy',
                 NULL,
                 NULL,
                 'online');
    COMMIT;
    CREATE TABLE id_table
       ids      VARCHAR2 (10),
       period   VARCHAR2 (10),
       loc      VARCHAR2 (10),
       dept     VARCHAR2 (10),
       code     VARCHAR2 (10)
    INSERT INTO id_table
         VALUES ('1',
                 '2010',
                 'nj',
                 '101',
                 'cc');
    COMMIT;

    Aj09 wrote:
    Hi Folks,
    I am facing a tricky challenge to join a table with multiple rows and converge into a single row (based on ID, period) and join with another table to get a single row. Let me explain.
    Table 1: DTL_TABLE (id, period, course, names, title, type)
    1 2010 mat john null null
    1 2010 mat jim null null
    1 2010 cam null officer null
    1 2010 cam null Prof null
    1 2010 phy null null Inclass
    1 2010 phy null null Online
    Join with
    Table 2: ID_TABLE(id, period, Loc, Dept, Code)
    1 2010 nj 101 CC.
    Output format (id, period, course, names, title, type, Loc, Dept, Code)
    result : 1 2010 mat,cam,phy john,jim officer,prof inclass,online nj 101 CC
    I have created all the DDLs and DMLs if that help. Kindly let me know if a Join SQL query is possible.
    SELECT TBL.id,
           DTLperiod,
           course,
           names,
           title,
           TYPE,
           Loc,
           Dept,
           Code
    FROM   ID_TABLE TBL,
           DTL_TABLE DTL
    WHERE  TBL.ID = DTL.ID
           AND TBL.PERIOD = DTL.PERIOD; it not good to use RESERVED WORDS like "ID" or "TYPE" as column names

  • SQL Update a Single Row Multiple Times Using 2 Data Sets

    I'm working in tsql and have an issue where I need to do multiple updates to a single row based on multiple conditions. 
    By Rank_
    If the column is NULL I need it to update no matter what the Rank is.
    If the Ranks are the same I need it to update in order of T2_ID.
    And I need it to use the last updated output.
    I've tried using the update statement below but it only does the first update and the rest are ignored. Here is an example of the data sets i'm working w/ and the Desired results. Thanks in advance!
    update a
    set Middle = case when a.Rank_> b.Rank_ OR a.Middle IS NULL then ISNULL(b.Middle,a.Middle) end,
    LName = case when a.Rank_> b.Rank_ OR a.Lname IS NULL then ISNULL(b.LName,a.LName) end,
    Rank_ = case when a.Rank_> b.Rank_ then b.Rank_ end
    from #temp1 a
    inner join #temp2 b on a.fname = b.fname
    where b.T2_ID in (select top 100% T2_ID from #temp2 order by T2_ID asc)

    The Merge clause actually errors because it attempt to update the same record.  I think this CTE statement is the closest I've come but I'm still working through it as I'm not too familiar w/ them.  It returns multiple rows which I will have to
    insert into a temp table to update since the resulting row I need is the last in the table.
    ;WITH cteRowNumber
    AS(
    Select DISTINCT
    Row_Number() OVER(PARTITION BY a.LName ORDER BY a.LName ASC, a.Rank_ DESC,b.T2ID ASC) AS RowNumber
    ,a.FName
    ,a.LName
    ,b.LName as xLname
    ,a.MName
    ,b.MName AS xMName
    ,a.Rank_
    ,b.Rank_ AS xRank
    ,b.T2ID
    FROM #temp1 a
    inner join #temp2 b
    ON a.fname = b.fname
    ), cteCursor
    AS(
    Select a.RowNumber,
    a.Fname
    ,a.LName
    ,a.xLname
    ,a.MName
    ,a.xMName
    ,a.xRank
    ,a.T2ID
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xRank,a.Rank_) else ISNULL(a.Rank_,a.xRank) end AS Alt_Rank_
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xMName,a.MName) else ISNULL(a.MName,a.xMName) end AS Alt_MName
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xLName,a.lname) else ISNULL(a.LName,a.xlname) end as Alt_Lname
    FROM cteRowNumber a
    where a.RowNumber = 1
    UNION ALL
    Select crt.RowNumber
    ,crt.FName
    ,crt.LName
    ,crt.xLname
    ,crt.MName
    ,crt.xMName
    ,crt.xRank
    ,crt.T2ID
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xRank,Prev.Alt_Rank_) else ISNULL(Prev.Alt_Rank_,crt.xRank) end AS Alt_Rank
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xMName,Prev.Alt_MName) else ISNULL(Prev.Alt_MName,crt.xMName) end AS Alt_MName
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xLName,Prev.Alt_Lname) else ISNULL(Prev.Alt_Lname,crt.xLName) end as Alt_Lname
    FROM cteCursor prev
    inner join cteRowNumber crt
    on prev.fname = crt.fname and prev.RowNumber + 1 = crt.RowNumber
    SELECT cte.*
    FROM cteCursor cte

  • How can I take text from a webpage that is in multiple rows and move it into a single row in Excel?

    I need help figuring out how to take data from internet pages and enter it into one single row in an excel, or numbers if that is the easier way to go.  I was also told access might be good to use.  Basically I am going to chamber of commerce page and wanting to extract the member listing and enter in a database in a single line.  The  data is in different numbers of lines as you will see below (info edited to take out personal info). So I want to take the  name of business, business owner, address, city, state, zip, and phone and put it into one line on a spreadsheet.  I want to do this many times over. I think there is a way to do it through apple script and automator, but I have not been successful after 2 weeks of trying and searching.  I have over 800 listings and I surely don't want to go through and do them one at a time.  Any suggestions?
    Data from website:
    Westrock Coffee
    Mr.
    Collins Industrial Place
    North Little Rock, AR 72113
    Phone:
    Send Email
    Member Since: 2011
    Sweet Creations by DJ
    Ms. J
    allace Bridge Road
    Perryville, AR 72126
    Phone:
    Fax:
    Send Email
    Member Since: 2013
    See Also Woman Owned and/or CEO
    Premium Refreshment Service
    Mr. E
    est Bethany Road
    North , AR 72117
    I want it to look like this
    Company name, owner name, address, city, state, zip, phone
    How can I get the extra data out of the way and remove the format so that it will go into excel?  Thanks for any help you can provide.  I am not to savvy with code, but I got a friend who is an IT guy that can help.  Thanks again

    So, basically, create 800 individual entries, each one containing everything from business name through the phone (not fax) number, add some commas and spaces to entries, and then put each entry on a separate line?
    1. Go to website page such as this one-- http://www.littlerockchamber.com/CWT/External/WCPages/WCDirectory/Directory.aspx ?ACTION=newmembers --which seems formatwise very close to what you're trying to scrape.
    2. Cmd-A to select all. Cmd-C to copy it to clipboard.
    3. Open freeware TextWrangler. Cmd-V to paste info from clipboard into a blank TW document.
    4. Remove lines from top and bottom so that only membership list remains.
    5. Process lines to remove everything from "Fax" line through "See Also" line. Only business name through phone number will remain in the file.
    --A. TW > Text > Process Lines containing . . .
    -----(check "Delete matched lines"; uncheck all others)
    -----Enter "Send Email" in the search box.
    -----Click Process.
    --B. Repeat 5A for other lines to be removed
    ------Member Since
    ------See Also
    ------Fax
    6. Insert markers to separate entries:
    TW: Search > Find . . .
    ------(check "Wrap around" and "Grep")
    ------in Find box: \r\r\r\r
    ------in replace box: \r***
    ------Click Replace All
    7. Remove remaining blank lines:
    TW: Search > Find . . .
    ------(check "Wrap around" and "Grep")
    ------in Find box: \r\r
    ------in replace box: \r
    ------Click Replace All
    8. Add comma and space at end of each line:
    TW: Search > Find . . .
    ------(check "Wrap around" and "Grep")
    ------in Find box: $
    ------in replace box: ,  (comma space)
    ------Click Replace All
    9. Remove all returns:
    TW: Search > Find . . .
    ------(check "Wrap around" and "Grep")
    ------in Find box: \r
    ------in replace box: (leave blank)
    ------Click Replace All
    10. Insert returns in place of markers:
    TW: Search > Find . . .
    ------(check "Wrap around" and "Grep")
    ------in Find box: \*\*\*,  (backslash asterisk backslash asterisk backslash asterisk comma space)
    ------in replace box: \r
    ------Click Replace All
    11. Remove trailing comma and blank on each line:
    TW: Search > Find . . .
    ------(check "Wrap around" and "Grep")
    ------in Find box: , $ (comma space dollar sign)
    ------in replace box: (leave blank)
    ------Click Replace All
    Import this text file into Excel or Numbers.

  • Multiple pages that edit a single row

    I have searched on tabs and editing a single row using multiple pages and I am confused. I don't want to use java as I am trying to not learn that too...
    What I am trying to do sounds like it has been explained before but let me do this again...
    I have a record that is too large to fit on a single screen. This makes for a cumbersome entry process. The record is actually broken into four "logical" chunks. Main, Sub1, Sub2 and Sub3.
    I have made a list that will allow the record to be selected and call the first logical page... L1.
    I have made tabs that show all the pages and allow me to navigate between them quickly.
    When I get to L1 all the data is there. I may not change any data on that page and go directly to L2 through L4. However the record is not brought forward onto those pages. So the pages are not related (and I don't have the terminology right I know :) and I could "link" the pages. So here is what I would like the application to do;
    1. Display a list and allow the user to select the record to edit.
    2. Upon edit go to the first page (tab).. this works
    3. Allow the user to select a tab and the page displays the data for the record selected
    4. Allow the user to complete the edits and save the record. Upon save the user is returned to the list in step 1.
    I was thinking there are several ways to do it... but I was hoping someone could save me a bunch of trial and error (emphasis on the error) ...
    1. When navigating off the page save the record, pass the key and re-read the record... ugly huh?
    2. Pass all the session data for the record over to the next screen. Is that possible? e.g pxx_field1 = pyy_field1
    The the question was does a template with two level tabs keep the record data between tabs?
    Any help is greatly appreciated.
    Sam

    I think this works... kinda
    1. I have a "list" that allows the selection of the item to edit.
    2. That list opens a page that is the "header" page for a tab set.
    3. Each page in the tab set uses the same "ID" to read the record and display the columns. That is how it would work if the list called each individual page.
    4. I modified the "slave" tabs to have the "ID" of the "header" page.
    This displays the correct data on each page. And it looks like the "apply changes" button saves the changes on the page.
    Caveats inlclude (I think as I haven't done exhaustive testing"
    1. "apply changes" must be done at each page where there were changes or they would be lost.
    2. The first dispaly of the page is blank. Clicking on the tab a second time displays the data. This is true if it is the first time a user selects a record in a session (the "slave" tabs are blank) or if it is a subsequent record update (the "slave" tabs have the last records data.
    Thoughts... is this really boring to everyone but me?
    Sam

  • Single row editing for multiple tables in a single page

    Hi!
    I have split a table with many many columns into more tables with a lower number of columns. There is an ID column (sequence generated) that is Primary Key common for all tables. Obviously, the relationship between these tables is 1 to 1, so it’s not about having to build master-detail pages.
    What I need now is to edit all these tables in a single page: one single row from each table. The Automated Row Fetch & Automatic Row Processing (DML) processes used for the old table must be replaced by something else.
    Is there a way to use in a single page more pairs of such processes for more tables?
    I want to avoid manually writing processes with lot of PL/SQL code to handle row fetch & update.
    Keep in mind that the page will have an ID item that can be used to identify unique rows in all my tables.
    Thanks,
    Sorin

    I have split a table with many many columns into more tables with a lower number of columns
    IMHO that is a very bad idea. There is nothing wrong with having many columns in a table. If you would like to split them to better "categorize" them, just create views on the table and expose different subsets of the columns.
    I want to avoid manually writing processes with lot of PL/SQL code to handle row fetch & update.
    That is unavoidable given how you have designed the underlying tables.
    You could try creating a view that joins all the tables by the PK and creating a form based on that view. Then write a INSTEAD OF trigger on the view that "doles out" the DML on the view to each of the underlying tables.

  • Multiple rows in a single row.

    I want to know how can I store the values of multiple rowe in a single row.for an example..
    machine name    manchine no  frequency   month
    Lathe                  MOO1          yearly         jan
    Lathe                  MOO1          halfyearly   feb
    Lathe                  MOO1         weekly       march and so on
    I want this in a single row..
    like                        jan       feb             march
    Lathe       M001   yearly     halfyearly   weekly.
    and in a single row I want this as per the month specified .
    In my report I have 12 months distribution for each machine.

    Taruna,
    Just make sure understand the scenario correctly. Would you like to store the row in DB like this:
    Lathe MOO1 yearly jan,feb,mar
    then you expect to show in the report like this:
    Lathe MOO1 yearly jan
    Lathe MOO1 yearly feb
    Lathe MOO1 yearly mar
    Yes, you can do it this way, but somehow break the 1st principle of DB schema design - Atomic
    Of course, you need to convert jan,feb,mar into list and display for each row.
    string monthStr = "jan,feb,mar";
    string [] months = monthStr.Split(",");
    Kind Regards
    -Yatsea

  • Merging multiple rows in to a single row (when rows meet merging criteria)

    Hi 
    I have a scenario to merge multiple rows in to a single rows when the data in those rows fall in merge criteria .Below is how my data is 
    Now the merging logic for the above rows is , we need to combine multiple rows in to a single row when the data in those rows permits us to do in that way. Simply saying , its like sandwich where we combine multiple things to a single piece.The output for
    the above rows should be
    Here  we combined Row 1 ,2, 3 in to a single row as the data in those rows permits to merge in to single row. But the row 4 cannot be combined to any of those rows because the data in those rows doesn't permits us do a merge ( As the value of the column
    JobSource for the row 4 is different from the other rows ) .
    My original data has 56 columns , but for readability i kept only 9 columns. 
    can you please throw some idea on how to achieve this scenario. I know we need to use CTE for achieving this, but i am not able succeed in doing an iteration on multiple rows.
    Appreciate your response .

    Thanks for your reply .
    Rule for merging is simple . First of all there is no unique row identifier for each row , the fact table is not having an identity column in the database . I called row 1 , row 2  etc in my post above only to make better explanation of my scenario.
    The rule for merge is below. 
    1) we can combine only when the data in a column for one row is null & the data in same column for the other row is not null . It should also satisfy the condition where the data in other columns should conflict each other.
    2) Data for all columns for the merging rows should not be conflicting (i.e. we should not merge the rows when the data in a column is not equal to the same column in the other row
    ,considering not null value)
    Steps in merging the above source data :
    1) Consider the case of row 1 and row 2 in the source, we can combine these rows as the data is satisfying the rule 1 for columns (Jobsource,Flight, Package,Update,Iscancelled
    ,Result, Severity) and columns (JobID and RuleName ) fall under rule 2.  we merge these two rows in to a single row and keep in that in the table.
    2) Then the resulting row is again merged with the second row which is present above by applying the rule 1 and rule 2 . Below would be output of merge operation.
    Now there would be only two rows in the output . But these rows cannot be merged as the data doesn't satisfy the merge rules 2 . As Jobsource for the row 1 in the above output is "PresubmissionSource" which is not equal
    to "PostSubmission" jobSource which is in row 2. So these two rows are left unmerged .So the above two rows would be the output of merge operation on my source data.
    This process has to be repeated for all the rows in the table. As of now my table as 92 Million rows with 56 columns which need to be considered for merging rows. I replicated my scenario in 9 columns and 4 rows to understand better.

  • Customizing Sharepoint Calendar Week Group View to display multiple weeks in a single row

    Hi,
    SharePoint Calendar's Week Group View is useful for comparing multiple co-worker's schedule, and we have a business needs to be able to view the schedule for with the date range of more than one week at a time between co-workers for planning purposes, is
    there a way (code or no-code) to manipulate the date/week range so that the calendar display more than 7 days in a single row?

    Hi,
    As there is no such OOTB feature, I would suggest that you can change the calendar scope to “Month” or create a Gantt view to display more weeks in a view.
    Or you can try to create a custom calendar web part to meet your requirement.
    Here are some samples of custom calendar web part for your reference:
    http://www.codeproject.com/Articles/108676/SharePoint-Custom-Calendar
    http://gunnarpeipman.com/2009/01/creating-sharepoint-global-calendar/
    https://blog.metrostarsystems.com/2013/10/21/creating-a-custom-sharepoint-calendar-rollup/
    Best regards
    Patrick Liang
    TechNet Community Support

  • Inserting table in web form/ Inserting multiple cells in a single row

    Dear Mr Johnson,
    Thanks for your early reply.
    I am rather disappointed .....as I need to distribute my form urgently with a table insertion capability.
    I had purchased Adobe webform central subscription with the idea that a paid subscription will fetch me the full editing capability of the Adobe form central web forms.
    Please inform me as to when this vital update regarding the table insertion/ multiple cells insertion in a single row capability (update) will be functional and available for our use as today is 26th of January, 2013.
    Kindly reply ASAP.
    Thanks,
    with kind regards,
    Dr Ali

    See this thread from two days ago where Randy Swineford of Adobe says that it is expected to be added at the end of January: http://forums.adobe.com/thread/1140470?tstart=0
    I don't know if it will include a table tool.

Maybe you are looking for