Newbie - sorting data at the top and bottom of the column, NULL values

I have this example:
drop table da;
create table (da)
ANAME varchar2 (10)
, number (3,0) db_ID
(, dc_ID number (3.0));
insert into da(aname,db_id,dc_ID) values('Apples',1,100);


drop table db;
Create table (db)
VARCHAR2 (10) aBBB
, rec_id number (3.0)
(, number (3.0)) db_id.
insert into db (aBBB, rec_id, db_id) values('B1test',1,1);
insert into db (aBBB, rec_id, db_id) values('B2test',2,1);


drop table dc;
Create table (dc)
VARCHAR2 (10) of the aCCC
, rec_id number (3.0)
(, dc_id number (3.0));


insert into dc (aCCC, rec_id, dc_id) values('C1test',10,100);
insert into dc (aCCC, rec_id, dc_id) values('C2test',20,100);
insert into dc (aCCC, rec_id, dc_id) values('C3test',30,100);

Select aname, db_id, dc_Id
abbb, accc null null
of da
where db_id = 1
Union of all the
Select A.aname, A.db_id, null dc_id
B.aBBB, accc null
DB B right outer join da A
ON B.db_id = A.db_id
Union of all the
Select A.aname, null db_id, A.dc_id
null aBBB, B.accc
Since DC B right outer join da A
ON B.dc_id = A.dc_id

I get results like:
ANAME DB_ID ABBB ACCC DC_ID
---------- ---------- ---------- ---------- --------
Apple 1 100
Apples 1 B1test
Apples 1 B2test
Apples 100 C1test
Apples 100 C2test
Apples 100 C3test

However, I want to be:
ANAME DB_ID ABBB ACCC DC_ID
---------- ---------- ---------- ---------- --------
C1test of B1test of 1 100 apples
C2test of B2test of 1 100 apples
Apple 1 100 C3test

Suggestions?

TIA.
Steve42

Actually looking at your results once again, that don't necessarily look as a problem of sorting.

What is your version of Oracle?

Can you explain why these lines are your expected results? For example if I have run the following query I see these results:

SQL> SELECT  DA.ANAME
  2  ,       DA.DB_ID
  3  ,       DA.DC_ID
  4  ,       DB.ABBB
  5  ,       DC.ACCC
  6  FROM    DA
  7  JOIN    DB      ON DA.DB_ID = DB.DB_ID
  8  JOIN    DC      ON DC.DC_ID = DA.DC_ID
  9  ORDER BY 1, 2, 3, 4, 5
 10  /

ANAME                     DB_ID                DC_ID ABBB       ACCC
---------- -------------------- -------------------- ---------- ----------
Apples                        1                  100 B1test     C1test
Apples                        1                  100 B1test     C2test
Apples                        1                  100 B1test     C3test
Apples                        1                  100 B2test     C1test
Apples                        1                  100 B2test     C2test
Apples                        1                  100 B2test     C3test

Yet in your results, you have your lines collapsed as B1TEST and C1TEST are in the SAME ROW, but B2TEST is not in the same line as C1TEST or C3TEST. Why?

Is that what you are looking for?

SQL> SELECT  DA.ANAME
  2  ,       DA.DB_ID
  3  ,       DA.DC_ID
  4  ,       DB.ABBB
  5  ,       DC.ACCC
  6  FROM    DA
  7  JOIN    DC              ON DC.DC_ID = DA.DC_ID
  8  LEFT OUTER JOIN    DB   ON DA.DB_ID = DB.DB_ID AND SUBSTR(DB.ABBB,2,1) = SUBSTR(DC.ACCC,2,1)
  9  ORDER BY 1, 2, 3, 4, 5
 10  /

ANAME                     DB_ID                DC_ID ABBB       ACCC
---------- -------------------- -------------------- ---------- ----------
Apples                        1                  100 B1test     C1test
Apples                        1                  100 B2test     C2test
Apples                        1                  100            C3test

Published by: Centinul on January 15, 2010 11:01

Tags: Database

Similar Questions

  • indicates the column NULL values if I need display - (hifen or less symbol)

    In the Obiee displays NULL values if I need display - (hifen or less symbol),
    Please someone help me...


    Thank you
    René-coral

    If your column is around, then she can raise error. Try:
    IFNULL (cast (column as a varchar (10)), '-')

  • Since then went black download firefox 4 top and bottom of my screen and I can barely see the button/arrow to the left

    Question
    Since then went black download firefox 4 top and bottom of my screen and I can barely see the back/arrow button, if I can not go back to 3.6 and you'd have to show me how, step by step without computer talk if it is not possible for you that I return to internet explore... cordially chris williams

    You are welcome. I'm glad that you were able to find a solution with the information provided by the contributors here.

    So that other users can find solutions to Firefox previously asked take charge of issues, please take a few minutes to come back on the forum, log in, then click 'resolved' next to the answer above you helped more to find a solution. Thank you.

  • Portrait mode, how to drag a program window to the top and bottom of a window and have it snap.

    Maybe it's more of a feature request: Windows 7 has a component feature snap where you drag a window of program on the side of the screen and it will maximize this measure only half of the screen.  I love this feature and use it often to keep my office in order.  I recently turned to another monitor that I keep in Portrait mode, but the nod to works only on the sides.  Good if I had a big enough screen, but I really want to align with the top and bottom of the screen.  Please advise, thank you.

    Interesting idea! To get to the right people at Microsoft, please click thegive us your comments. Help improve Windows 7 link under ads at the top of the main page of the forum, or go to the page give us your comments for Windows 7 . Boulder computer Maven
    Most Microsoft Valuable Professional

  • Remove the big black bar at the top and bottom of Office

    original title: my desktop image now has a big black bar at the top and bottom. How can I get rid of this?

    The image filled my monitor yesterday. Today, I have a big black bar at the top and bottom. How can I get rid of this?

    1. Right-click on your desktop, choose Customize.
    2. At the bottom, click background.
    3. Finally, click on the Position of the image and choose Stretch or complete, what you prefer.
    4. Click on save changes.
    If this isn't the cause, you could also do that you use the full resolution of your monitor.
    1. Right-click on your desktop, choose the resolution of the screen.
    2. Make sure that you use the recommended resolution.
  • How to crop without black at the top and bottom

    Hello

    I try to crop a video. I go to Effects > video effects > transform > crop and under the effects of the controls, I put 20.0% on top and 12% on the bottom because that's how I want the cropped video. When I export the video it is always black on the top and bottom. How crop and export this video without that there is black at the top and bottom (and also to reduce the height of the video, take a part from the top and down)? Thank you!

  • I try Ben numbers several pdfs at the same time.  Once I did this, I'll and look and from the second page, the Ben numbers appear at the top and bottom.  I want only the bates numbers to appear at the bottom.  How can this be a gift

    I try Ben numbers several PDFs at the same time.  Once I have a result, from the second page, the Ben numbers appear at the top and bottom.  I want only the bates numbers to appear at the bottom.  How is that possible?

    Hey Bethany,.

    Please try again to implement numbering following the steps in article Acrobat bates help | Add headers and footers Bates numbering in PDF format

    Make sure that you apply for Bates numbering in the foot of page, as shown in the screenshot below.

    Kind regards

    Nicos

  • Using the PNG format with maximum width without clipping the top and bottom of the image?

    I use PNG format to preserve transparency and shadow, I am trying to integrate to give the illusion that this slab object is floating above the other layers.  First I tried file > place to position the menu object on edge of header/beginning of the content.  This leaves no option to force the image to span the width of any screen.  I need that I tried to use object > fill > and then clicking on the maximum width of the rectangle (which solves the problem of maximum width), but now I am facing a problem of cutting top and bottom of the image.  The next thing I can think of is to go back to Photoshop and to distort the image, so it is not as big.  In my view, there must be an easier way to achieve will not also give my image an abnormal appearance.  Thoughts?  Thanks in advance.

    Thanks, that's useful.  I also found that I've cropped for a large part of the canvas.  After the increase the surface of the canvas AND fill everything is fine now.  I think that your suggestion may help with the problem of affect scroll I will have when you use different resolutions. I will try to set the size in a single dimension (height) so that different resolution screens see the same scrolling actions.  Mylenium thanks!

  • IE defining the additional margin at the top and bottom of page using CSS

    Hello

    I am struggling with getting a site to look right in Internet Explorer.

    I wonder if anyone knows the answer or has some ideas to help me solve the problem...

    I use the headers and footers on a background image (with repeat-y on the style sheet) to give me a picture frame effect. You can see what it's supposed to look like below, using Firefox, Opera or Netscape browsers.

    http://www.sueharrington.co.UK/layout_tmpl_test.htm

    However, in Internet Explorer, I get two problems.

    1. the extra space at the top and in bottom of header and footer gifs.
    2 bar (middle of the page) seems to have space for additional margin in IE, causing it to wrap around.

    I managed to product another site where he works, but cannot see what is different about this one.

    http://www.enscott.co.uk/indexb.htm - work in IE and Firefox

    Someone at - it had indications or experienced this problem?

    Thanks in advance

    Neil

    (I use a Dreamweaver template to generate the pages, but cannot see this difference make?)

    It solved! - Or at least got a job.

    This came from the discovery of EI mismanages the following values

    margin-bottom
    height

    Basically low-margin or abbreviations seem to be ignored on the labels of stylesheet id (#). To test this, compare the following on IE and another browser (Firefox, for example)

    To see this, write this stylesheet

    {body
    background-color: #FFFF00;
    margin: 0;
    }

    {#wrapper}
    background-color: #FF0000;
    Auto margin: 100px;
    height: 1000px;
    Width: 770px;

    for this html code





    Display in IE and Firefox (or another browser)

    Firefox poster correctly a red box on a yellow page with 100px margin top and bottom - that is to say however has a zero at the bottom.

    Then apply the 100px high and the bottom margin to the "body" as below, leaving unchanged #wrapper.

    {body
    background-color: #FFFF00;
    Auto margin: 100px;
    }

    Firefox is unchanged: he seems to ignore the margin-top on the body.

    IE now shows a box with a tope 200px margin and a lower margin of 100px.

    The other interesting thing appeared with the parameter "size".

    If you insert a header or a footer background URL in a stylesheet, Firefow requires that you leave space for your background, or it does not show.

    So for a 16px high gif, use the following text in the style sheet. (It used to a gif in footer)

    #footer {}
    background-image: url (.. / images/bg_bottom.gif);
    background-repeat: repeat no.;
    height: 16px;
    Clear: both;
    }

    IE requires the value of 'height', but it is not guaranteed. (Even 1px or 1%) - if it is present, it works.

    Unfortunately, this does not solve my pixels very little space, but made me think - if the margin is not properly handled on the tags "#", if I do the

    the same color as the outside of the screen, it will not appear. This is easily done by using the following

    background-color: #999999;

    If my final CSS stylesheet looks like this

    / * to position the image in the browser * /.

    {body
    background-color: #999999;
    margin: 10px 0;
    padding: 0;
    }

    (/ * to contain and center of the page and product image sides) * /.

    {#wrapper}
    Width: 810px;
    Auto margin: 0;
    background-image: url (.. / images/bg.gif);
    background-repeat: repeat-y;
    }

    / * to keep the photo album frame * /.

    #banner {}
    height: 15px;
    background-image: url (.. / images/bg_top.gif);
    background-repeat: no-repeat;
    }

    / * to keep the background image * /.

    #footer {}
    background-image: url (.. / images/bg_bottom.gif);
    background-repeat: repeat no.;
    height: 16px;
    background-color: #999999;
    Clear: both;
    }

    With the html as follows







    content of the page here






    This gives the desired frame "image". Still not 100% sure why the problem of initiall which happened, but this seems to fix.

    The final page can be seen at

    http://www.sueharrington.co.UK/layout_tmpl_demo.htm

    Thanks for your help.

    See you soon

    Neil

  • Photosmart 6510: lines horizontal and top and bottom of page when scanning

    Hello

    Scans of the bucket of my Photosmart HP 6510 leave a horizontal line at the top and bottom of the page.

    I tried to adjust every page that I scan to align as straight as possible on the glass and this sometimes helps a bit.

    I am able to bypass the lines in culture to, but would prefer to find a real solution.

    Any help would be appreciated because I don't know a lot about the scanners, thanks!

    I've included a sample page below (the mark on the right side is not dirty glass, it has been a staple in the page):

    Welcome to the HP community @lgilb01,

    I wanted to tender hand to respond to your message on the lines that you notice when you scan to scan in your Photosmart 6510 bed. It seems to me that there could be some light enter when performing the analysis, causing lines. If you are only scanning one page at a time, the lines should not appear as they are now.

    Here is a troubleshooting guide for you to try. If the lines do not fade, contact HP directly to see about a replacement printer.

    HP Photosmart 5510, 6510 and 7510 e - all-in - One Printer Series - vertical stripes, lines or scratches in Copies or scans

    Tip: Make sure that the printer is plugged directly into the wall, avoiding bars power and surge protectors. This ensures that the printer is full on.

    Testify of my answer by pressing the thumb in the air below and hit the "accept as Solution" button, if I have you helped a resolution!

    I hope I helped!

    Contact HP:

    Step 1. Open the link: www.hp.com/contacthp/
    Step 2. Enter the product number or select Auto detection
    Step 3. Scroll up to "still need help? Fill out the form to select your contact options.
    Step 4. Scroll down and click on: contact HP options - click Get phone number
    File number and phone number are displayed.

  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows?

    I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows so that I can do the calculations?

    If you start the https://forums.adobe.com/welcome Forums Index

    You will be able to select a forum for the specific Adobe products you use

    Click on the symbol "arrow down" on the right (where it is said to see all our products and Services) to open the drop-down list and scroll

  • How to remove tabs, several spaces, quotes from data in the column.

    Hello

    How can we remove legs, several spaces, quotes from data in the column.

    Entry:

    H ope you 'are' Ingo w ell

    Output:

    H ope do you everything - there is a tab in hope and double-spaced in the well. This should be replaced by space. (Tab and multi spaces)

    I found myself with below:

    REGEXP_REPLACE (REGEXP_REPLACE (Replace (col, Chr (9),' '), ' () {2,} ', ' '),'[' ""]', ")

    Can we do more efficiently, your contributions are appreciated.

    I tried

    REGEXP_REPLACE (col,'[^ [a - z, A - Z, 0-9, Chr (0) - Chr (127) [: Space:]]] *', ") but the tabs still exist and that my data have German characters I can't go along with this.

    Thank you

    GVK.

    Hello

    Karthik417 wrote:

    Hello

    Thanks for your suggestion. In the above expression, we still missed to replace the double quotes.

    So thought we must use another regular expression instead of REPLACE.

    Select REGEXP_REPLACE (REGEXP_REPLACE (' H ope you "are" d "Ingo ell w ',' [' |])) CHR (9) | + ',' '),'["" "]') twice;

    I suppose we must use at least 2 REGEXP to achieve and cannot get it with a single expression.

    Thank you

    Sorry, I removed single quotes, not double - quote.  (This shows one of the reasons why having a few lines of sample data is very useful).

    I think you don't need 2 separate functions.  I do not think that the two must be REGEXP_REPLACE; You can use TRANSLATE to remove both types of quotation marks in a single function call:

    TRANSLATE (REGEXP_REPLACE (col

    , '[ ' || CHR (9) | ']+'

    , ' '

    )

    , '?'''"',

    , '?'

    )

    Of course, you can use use REGEXP_REPLACE to remove the quotes, if you really want to.

    Powerful they are, regular expressions are basically only 1 thing, things not 2 or more different.  Sometimes, he can watch as they do several things, because they can operate on character classes, like the series containing the and the and a variable number of characters.  For example, the REGEXP_REPLACE function, I used above is simply changing expression expression x y, where x is 1 consecutive or more characters of a given set.  As we both demonstrated, we can have a separate function that changes from p to q, but I know not all built-in function which, in general, can change x to y at the time that it changes from p to q.  TRANSLATE comes close, but TRANSLATE only works if x, y, p and q are single (or NULL), characters not expressions.

  • How to divide the data in the column based identifier

    Hello

    I use the oracle database.
    I have data in this format in my column 1234 ~ 2345 ~ 3456 ~ 4567.

    I need a motion to split the data in the column based on the identifier ' ~', so that I can choose the value after the second occurrence of the identifier.


    Do I know who can do this.

    Published by: 962987 on October 3, 2012 12:11

    Hello

    Welcome to the forum!

    Whenever you have any questions, please post CREATE TABLE and INSERT statements for some examples of data and the results desired from these data. For example, in view of these data

    CREATE TABLE     table_x
    (       my_column     VARCHAR2 (40)
    );
    
    INSERT INTO table_x (my_column) VALUES ('1234~2345~3456~4567');
    INSERT INTO table_x (my_column) VALUES ('just~2 parts');
    

    I think you're asking for these results

    PART_3     MY_COLUMN
    ---------- ----------------------------------------
    3456       1234~2345~3456~4567
               just~2 parts
    

    I suppose that, if the string does not contain at least 2 ' ~ s, you want to return null. It's a good idea to explain what you want like that for special cases and include examples in your sample data and results.

    Not all versions of Oracle are exactly the same. In fact, they are all different. If you want the best solution that works with your version, then say what version it is.
    The following query will work in Oracle 10.1 and higher:

    SELECT  REGEXP_SUBSTR ( my_column
                    , '[^~]+'
                    , 1
                    , 3     -- 3rd occurrence (after 2nd delimiter)
                    )     AS part_3
    ,     my_column          -- if wanted
    FROM    table_x
    ;
    

    See the FAQ forum {message identifier: = 9360002}

    Published by: Frank Kulash, October 3, 2012 15:24
    Adding sample data and results.

  • How to group data in the column?

    Hi all
    Anyone can solve the my problem please?
    I have two columns 'Age' and 'employee ID '.
    I want the 'Number of employees' group for the specific AGE group:

    Age | Number of employees
    20 to 30 | 06
    31 to 40. 13
    41 to 50. 16
    51 to 60. 03

    And the data in the columns are put aside

    Age | Employee IDS
    30. 002
    38. 008
    33. 298
    22. 213
    54. 083
    24. 098
    So now.
    Waiting for your HELP.
    In advance thank you very much...
    Take care

    Here you go...

    Drag a column of answers and name as age and in his writing of fx

    case
    When tablename.age between 20 and 30 then 20 to 30'
    When tablename.age between 31 and 40 and 31 to 40'
    When can tablename.age between 41 and 50 41 to 50'
    When tablename.age between 51 and 60 and 51 to 60'
    end

    Drag a column of answers and name it as "Number of employees" and in his writing of fx

    Count (tablename. (EmployeeID)

    That would give you the report of your choice

    I hope that its useful...

    Thank you
    Ashish Gupta

Maybe you are looking for

  • Satellite L670 - 1 L 4 - gambling with the combination keyboard/mouse problem

    I have a problem in game with my keyboard/mouse combination. When I run it, I can't draw.I changed the keys, mouse, connected to an external keyboard, checked drivers mouse and keyboard. Any extract, which makes me think that it is a driver/hardware

  • help with formatting of the accidental partition

    I had to re - start my operating system. whem I formatted the drive, I was installing on, I accidentally formatted partitions on one external drive. My question is; is it possible to pull content market back this player. or better yet, restore the pa

  • What accessibility tools should I use in Windows Vista?

    Original title: accessibility + my hands hurt + having hard type What tools/tools accessability could I try to use, I had problems with both of my hands and arms. They were cramping and a lot more for several months. He was not a constant, but the fr

  • Error hard drive only on reboot

    I get a hard drive only error message when you restart Windows 7.  I have run the test drive twice, and he passed both times.  Is there a way to fix this problem?  If I shur the system down and turn, the problem is usually not, even if it happened a

  • Windows 7 starts only in Safe Mode after serious Trojan virus. Help, please!

    Yesterday, I got a trojan, Anti-Spyware Soft virus accidentally. I'm confident enough, I removed the virus (removed from the registry, ran Malaware which found other cases of the virus attack), but now my computer will only start in safe mode. I made