How to split one record to two?

I am still trying to come up a good example. If you know any, please suggest. I will shoot the question out first.
The base tableA:
colA colB colC colD colE
==================
1 Y 100 23 564
2 N 65 345 23
3 Y 211 940 999
So i need to create a VIEW based on the above table. If the colB has value Y, that record will be split to two. if it's N, just copy all the data
colA colB colC colD colE
==================
1 Y 100
1 N 23 564
2 N 65 345 23
3 Y 211
3 N 940 999
Please keep in mind, this is a simplified view. The real view I created has about 40 columns. 'Union All' seems to be tedious if I have copy like 37 columns with only 3 columns have different values.
Oracle 10gR2.
Thanks.

new2Oracle wrote:
Thanks.
As a learning experience, please explain your approach to this solution.
Edited by: new2Oracle on Mar 22, 2010 1:44 AMYeah, sorry about the first post. I read 2 lines of your sample data and made up the rest in my head so missed a case :)
This should mimic your sample output.
ME_XE?with your_data as
  2  (
  3     select 1 as col1, 'Y' as col2, 100  as col3, 23  as col4, 564  as col5 from dual union all
  4     select 2 as col1, 'N' as col2, 65   as col3, 345 as col4, 23   as col5 from dual union all
  5     select 3 as col1, 'Y' as col2, 211  as col3, 940 as col4, 999  as col5 from dual
  6  ),
  7     dual_data as
  8  (
  9     select 'Y' as col2 from dual union all
10     select 'N' as col2 from dual
11  )
12  select
13     y.col1,
14     case when y.col2 = 'N' then y.col2  else d.col2                                        end as col2,
15     case when y.col2 = 'N' then y.col3  else decode(d.col2, 'Y', y.col3, y.col4)           end as col3,
16     case when y.col2 = 'N' then y.col4  else decode(d.col2, 'Y', to_number(NULL), y.col5)  end as col4,
17     case when y.col2 = 'N' then y.col5  else NULL                                          end as col5
18  from your_data y, dual_data  d
19  where d.col2 = 'Y'
20  or    d.col2 != y.col2
21  order by y.col1, d.col2 desc
22  /
              COL1 COL               COL3               COL4               COL5
                 1 Y                  100
                 1 N                   23                564
                 2 N                   65                345                 23
                 3 Y                  211
                 3 N                  940                999
5 rows selected.
Elapsed: 00:00:03.56
ME_XE?As for the explanation ... you need to make up 2 rows to join to (the data from dual) and then remove rows where you have a N value from your existing data (since you only want a single row in that instance). From there you need to determine what type of data you have in your select statement (hence all the case statements).
Hope that helps.

Similar Messages

  • How to split one scene in two in iMovie HD 06

    Hi there, is iMovie HD 06 able to split one scene in two? I am trying to insert slow motion for part of the scene but not the whole. Can I do that? Are there alternatives?

    Easy. Select the clip you want to split, therefore highlighting it, move the playhead to the point that you want to start your slo mo, go up to EDIT and select Split Video at Playhead. Repeat for the end point of that slo mo bit and you are left with three separate clips.

  • How to split  the records into two parts

    Hi experts,
    I have a field with 75 char length, this field have records also, Now i want to split the field into two differnt fields. That means upto first 40 char goes to one field, from 41st char to 70 char goes to another field, for that how to split record into two parts.
    Plz advice this,
    Mohana

    Hi,
    Do the following:
    f1 = fsource(40).
    f2 = fsource+40(30).
    where fsource is the 70 character original string and target strings are f1 (length 40) and f2 (length 30).
    Cheers,
    Aditya
    Edited by: Aditya Laud on Feb 22, 2008 2:10 AM

  • How to split one monitor into two, differently configured desktops

    Hello,
    I have a 27" iMac. I would like to split the screen into two differently configured desktops or monitors. Apps like TwoUp or Divy don't exactly do this. I'll explain it with an example:
    Suppose I'm working on a document and I need to open many folders to retrieve files. One common problem is that opened folders overlap each other and sometimes they overlap with the document I'm working on, or they go underneath the document. I would like to split the screen vertically in, say, two virtual, independent desktops/monitors, like this:
    - one window/space on one side (say, on the left) of the screen would contain the document  from top to bottom, with no dock bar on the bottom
    - the other window/space (right) would behave as a regular, full desktop, with the entire dock on the bottom
    In this way, if I need to navigate to find a file to use in the document, I would move the cursor to the right. The Finder would work only in this window/space, thus windows or other applications would never overlap or clutter the left side of the screen. Drag-and-drop from right to left should be possible.
    One way to imagine it is as if the 16x9 monitor were comprised by two vertical, 8x9 independent monitors side by side, each with its own configuration.
    Is this possible? Can anyone recommend an application or type of setup?
    Thank you,
    -celso

    Looking for something like this?
    You can tell Display Maid to save the positions of your open windows across many apps and later restore those positions when things become a mess. With Display Maid you don’t have to restore windows one at a time, or even one app at a time. Display Maid restores all saved window positions across all apps with one command. It will also restore window positions automatically when it detects a workspace change.
    http://www.funk-isoft.com/index.php/display-maid

  • How To Split One Record  into 30 Records(Number of days in a Month)

    Hi Experts,
      we are getting the montly(yearmonth) Forecast data from flat file we need to generate the report which shows the daily Forecast data,
    For example for the month of June Forecast we have  150EA.
    Flat file data is like this
      0calday    Qty
      201006     150
    we need to show the report like datawise
       Calday                                     Forecast qty
    20100601                                          5
    20100602                                          5
    20100603                                          5
    20100604                                          5
    20100605                                          5
    20100606                                          5
    20100630                                           5
    its like month forecast / Number of days in a month.
    we can achive these  in two ways as per my knowledge
    1. At the time loading data
    2. Reporting level
    Which is the best way
    how can we achive this.
    Thanks
    Chandra

    Hey.  There was a similar posting I gave a suggestion on a while back.  Here is the link...
    Re: Spliting records into cube
    As far as the correct time of doing this, I would definitely do this at the time of data load and not time of reporting. 
    Hope you find it helpful.
    Thanks

  • PRE9: How to split one clip into two (or more) clips?

    I can't believe this is so hard to do... But HOW?

    You don't necessarily need to separate the file into individual clips.  When you do a cut on the timeline, this is a virtual cut, leaving the original file untouched but determining what will appear in the output.  You can split the clip into multiple pieces, delete the bits you don't want, add transitions, insert new bits, whatever you want, all without affecting the original file in any way.  Once you're happy, you output a new file using the Share options, and you get a new video file, with your original files still untouched.
    If you want to split your file into multiple individual files, you can use the sliders on the time scale, and export (Share) using the Share Work Area Only checkbox.  If you're doing this for purposes of reassembly, it would be better to save the individual clips in as lossless a format as possible, the default AVI format taking considerably more space but not losing quality.  Hint: the sliders can be positioned to the time marker using Alt-[ and Alt-].  Once you've done this, note that your original file will still be there, untouched.
    There is also VideoRedo Plus, a cheap program which gives frame-accurate selection and allows rapid subdivision of a piece of footage.  It doesn't re-render as PE9 would (this is where loss of image quality creeps in using compressed formats such as MPEG), copying the original frames.  You can then reassemble the bits using your video editor.

  • How to SPLIT ONE STEREO TRACK'S L & R CHANNELS INTO TWO MONO CHANNELS

    Does anyone know if this is possible: How to SPLIT ONE STEREO TRACK'S L & R CHANNELS INTO TWO MONO CHANNELS?  There's got to be a way, but I just can't find out how.
    I recorded a podcast -- me and a guest, with each mic going to its own mono channel. When I opened it in Audition it mixed them into one stereo channel. 
    Thanks in advance for any help.
    Best,
    Shawn 

    You're a big help! Thanks very much.  Simple yet I must be going blind because I didn't see that in the menu.
    Take care and THANKS AGAIN.
    Shawn

  • Split one IDoc into two IDocs ?

    hello all,
    I wanna split one IDoc into two IDocs in XI?
    how can implement it?
    plx give some suggestions.
    thx in advance
    best regards
    Yaning
    Message was edited by:
            Yaning Liu

    Yaning,
    Please find the below blog for changing the ocurrences of IDOC
    /people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change
    Best regards,
    raj.

  • Hello, I would like to know how to transfer one of my two "membership" to an other computer because I just bought a new Mac.... ? Or how to cancel it on my old laptop so I can activate it on my new computer. Thanks a lot !

    Hello, I would like to know how to transfer one of my two "membership" to an other computer because I just bought a new Mac.... ? Or how to cancel it on my old laptop so I can activate it on my new computer. Thanks a lot !

    Hi Virginie,
    You need to go under the help menu option and sign out from Muse and then install it on the other computer that you want using the creative cloud desktop app.
    - Abhishek Maurya

  • How to manage one library with two accounts

    how to manage one library with two accounts

    you can only be logged into one account at a time on the iTunes store. However, you can authorize your computer for both accounts, making your computer work with both. In the menu bar just click [Store > Authorize Computer]

  • How to split invoice/document  into two venders?

    Can anyone please tell me how to split invoice/document into two vendors.  Like if I get an invoice for $1000 and it needs to be splitted between father and son, $500 to each.  How would I set that up in SAP?  I am not sure if this will be an invoice split or a document split.
    Thanks
    Monika

    If you are using an FI  entry F-43 to generate invoice this can be done by giving the same invoice ref. in the Inv. Ref. field  for two vendors. This is manual
    Document Split will split the document between two profit center and not between vendors.

  • How to Split one SAP instance to Multiple Instances?

    Can any one guide me how to Split one SAP instance to Multiple Instances?
    Thanks in Advance.
    Regards,
    VB

    Sure, just extract the pages to a new file. The form fields will stay in
    place.

  • ICal splits one event into two, how do I fix this?

    I have one weekly repeating event entered.  For the first two weeks it shows up like normal, as one event.  But two weeks later it splits that one event into two different side-by-side bubbles.  I did not alter the event.  Does any one else have this problem?  How can I fix this?

    That is because you are sharing an Apple ID.
    On both phones go to:
    Settings > Facetime > turn off iPhone Cellular Calls
    I would also suggest you check here to make sure your husbands number is not checked on your phone or yours on his:
    Settings > Messages > Send & Receive
    Settings > Facetime
    Otherwise you will get each others Messages and FaceTime calls.
    I recommend that you each get your own Apple IDs if for nothing else than iCloud, iMessage & FaceTime.

  • HOW TO PRINT ONE RECORD PER ONE PAGE

    Hi I have report , with two queries. Each query has one group with the same data. lets say the queries are Q1 and Q2. The Groups are with column DeptNo, and DeptNo1 both pointing to the same column DEPTNO. Now I want to design it in such a manner that it shoudl print each group , one record per page, but same group on the same page. For Example
    ON PAGE 1
    DpetNo 10
    Emp1
    Emp2
    Emp3
    DeptNo1 10
    Emp1
    EMp2
    Emp3
    ON PAGE 2
    DeptNo 20
    Emp4
    Emp5
    DeptNo1 20
    Emp4
    Emp5
    ON PAGE 3
    DeptNo 30
    Emp6
    Emp7
    Emp8
    DeptNo1 30
    Emp6
    Emp7
    Emp8
    How the lay our will be ? What will be the conditions. I can set the property in each group to print one record per page. But how to make it so that it will print like above.
    Thanks
    FEROZ

    Hi Feroz,
    You can create a query Q0 to return DeptNo 10, DeptNo 20..... and make it as the parent of Q1 and Q2. Then you can print one dept per page.
    Regards,
    George

  • How to split a text in two parts?

    Hello everyone,
       I'm trying to make a text appearance, with a smilar effect as the one in this video (1 mn 43) :
    After Effects Template : 65 Title Animations - YouTube
       My problem is, I'd like to split my text in two parts, at the middle of a letter, so I can separate the text in two parts then gather it up at the end of the animation.
      I've tried to take a look at the text's animation tool, where you can make it spin, or rotate and this kind of stuff, but I can't find out how to make a letter really split at its middle.
    Thank you in advance and sorry for my english.

    Duplicate your text layer and mask.

Maybe you are looking for

  • AW version 4.3.0.26 installation story on a Torch 9800

    This story began when I received a message that AW version 4.3.0.26 was available. I have a Torch 9800 with software version 6.0.0.706 and for the last 2 years every time I tried to install a new version of AW I ran into icon issues, either by clicki

  • In a small media lab we have approximately 10 iPads on order. We'd like to purchase iMovie for all of the iPads. Best way to do this?

    Do we need to specifically create 10 separate iTunes user Apple IDs? Can we use 1 ID and share the app for multiple users/ iPads? Or do we use 1 ID and buy the app separately on all 10 iPads? I want to do this correctly and as recommended.  Thank you

  • Bootcamp XP on snowleopard to mountain lion

    I am intending to upgrade my OSX from 10.6 to 10.8. I am running window XP on bootcamp as well. As XP is not supported on 10.8, may I know what will happen to it after the upgrade to 10.8? Will it be usable? Or do I need to remove it before the OSX u

  • Ai - PDF issues

    Hi! I have problem with saving in PDF. I am croatian and we are use č,ć,ž,š,đ whan I go to my AI file I am see č,ć,ž,š,đ  and whan save in PDF everything is great. But Whan i open PDF file i have small "cube" instead č,ć,ž,š. This is picture of issue

  • Itunes slows down my computer with windows XP

    When Itunes is on it uses almost 95pct of the UC making slowing down or even stopping all processes working at the moment. It is the new 6.0.1.3 version downloaded on c:\ drive and all my playlist is located on an externat hard drive. Any idea ? Than