Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Need help with complex requirements

thinkingeyeSep 14 2010 — edited Sep 15 2010
Hi All,
WITH sample_data AS
     (SELECT '1' AS bin_data_id, '539' AS traffic_sample_id,
             '0015' AS end_intv_time, '0' AS bin_1_data, '24' AS bin_2_data,
             '19' AS bin_3_data
        FROM DUAL
      UNION ALL
      SELECT '2', '539', '0030', '0', '24', '55'
        FROM DUAL
      UNION ALL
      SELECT '3', '539', '0045', '0', '51', '17'
        FROM DUAL
      UNION ALL
      SELECT '4', '539', '0100', '0', '65', '27'
        FROM DUAL
      UNION ALL
      SELECT '5', '539', '0115', '0', '99', '48'
        FROM DUAL
      UNION ALL
      SELECT '6', '539', '0130', '0', '426', '138'
        FROM DUAL
      UNION ALL
      SELECT '7', '539', '0145', '0', '151', '62'
        FROM DUAL
)
SELECT *
FROM SAMPLE_DATA
And the output is as follows:
BIN_DATA_ID	TRAFFIC_SAMPLE_ID	END_INTV_TIME	BIN_1_DATA	BIN_2_DATA	BIN_3_DATA
					
1	                          539	                      15	                       0	                         24	                       19
2	                          539                       30	                       0	                         24	                       55
3	                          539	                      45	                       0	                         51	                       17
4	                          539	                    100	                       0	                         65	                       27
5	                          539	                    115	                       0	                         99	                       48
6	                          539	                    130	                       0	                        426	                      138
7	                          539	                    145	                       0	                        151	                        62
What i wanted to do is get rid of the first record ( i can use the row_number!=1 condition), but i want it to add it as new record at the last with the data as that of the previous last record like below:
BIN_DATA_ID	TRAFFIC_SAMPLE_ID	END_INTV_TIME	BIN_1_DATA	BIN_2_DATA	BIN_3_DATA
2	                         539	                  30	                        0	                      24	                      55
3	                         539	                  45	                        0	                      51	                      17
4	                         539	                100	                        0	                      65	                      27
5	                         539	                115	                        0	                      99	                      48
6	                         539	                130	                        0	                    426	                     138
7	                         539	                145	                        0	                    151	                       62
1	                         539	                  15	                        0	                    151	                       62
Please need help

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 13 2010
Added on Sep 14 2010
11 comments
704 views