Insert a blank line after each line grouped

Oracle 11.2.0.1

Windows XP

I need to create a table (who have more to exported to the Excel SQL Developer) something like this:

The user Scott Table Emp


create the table temptbl as

SELECT

-case when lead (deptno) OVER (ORDER BY deptno) = deptno then empno otherwise null end AS empno.

-case when lead (deptno) OVER (ORDER BY deptno) = deptno then ename otherwise null end AS ename.

-case when lead (deptno) OVER (ORDER BY deptno) = deptno then job otherwise null end AS work,

-case when lead (deptno) OVER (ORDER BY deptno) = deptno then null deptno otherwise end up LIKE deptno

WCP

Table created.

SQL > select * from temptbl;

EMPNO, ENAME, DEPTNO JOB

---------- ---------- --------- ----------

7782 CLARK MANAGER 10

PRESIDENT OF 7839 10 KING

7566 JONES MANAGER 20

FORD ANALYST 20 7902

7876 ADAMS CLERK 20

SMITH CLERK 20 7369

7521 WARD SALESMAN 30

7844 TURNER SELLER 30

7499 ALLEN SALESMAN 30

EMPNO, ENAME, DEPTNO JOB

---------- ---------- --------- ----------

7900 JAMES CLERK 30

MANAGER OF 7698 30 BLAKE

14 selected lines.

SQL >

But it is not giving me the last row of deptno.  If I have to display the data on sqlplus then I can use break on jump 1, but since I create my correct query table (around 10 K lines), I just want to insert a blank line after each data grouped.

Thank you.

Select empno, ename, job, decode (empno, null, null, deptno) deptno emp

Group by grouping sets ((empno, ename, job, deptno), deptno)

/

EMPNO, ENAME, DEPTNO JOB
----- ---------- --------- ----------
7782 CLARK MANAGER 10
PRESIDENT OF 7839 10 KING
7934 MILLER COMMITTED 10

SMITH CLERK 20 7369
7566 JONES MANAGER 20
7782 CLARK MANAGER 20
SCOTT ANALYST 20 7788
7876 ADAMS CLERK 20
FORD ANALYST 20 7902

7900 JAMES CLERK 30
7499 ALLEN SALESMAN 30
7521 WARD SALESMAN 30
7654 MARTIN SALESMAN 30
SALESMAN 7698 BLAKE 30
7782 CLARK MANAGER 30
7844 TURNER SELLER 30

Tags: Database

Similar Questions

  • Insert a blank line in the query output

    Is it possible to insert a blank line between two rows of the query output?

    In the EMP table, the column LINES is as follows:

    LINES
    1
    2
    3
    4
    1
    2
    3
    1
    2
    3
    4
    5

    I want to insert a blank line after every 1

    Please suggest.

    Sanjay

    I'm quite puzzled why you need rows in the dataset returned by a select statement that is empty.
    If you are using Oracle reports to the release date, you define the presentation of the report to have spaces between the rows returned by the select and have do not need to have the select statement returns a blank line after each line of data. If the output should be obtained by using another client, I think that the customer will have facilities for output formatting.

    Admit that you really need "blank lines" between data lines, I see only one way: use a temporary table and do an insert into select temporary_table (...) ... from... where... Then, in this temporary table, you can insert 'empty rows', which is actually not really empty, because they must have some fields that give the order of the rows. And then select in temporary_table, you place your order by the columns that are used to give the order for the release.
    Thus

    insert into temporary_table (
    ....
    )
    select ...
    from ...
    where ...
    ;
    for r in (
    select col1, col2, col3  -- columns used for order by
    from temporary_table
    order by col1, col2, col3
    )
    loop
      insert into temporary_table (col1, col2,col3, col4)
      values (r.col1,r.col2,r.col3, null);
    end loop;
    -- this way, a select * from temporary_tabel order by col1, col2, col3, col4 will return a blank row after each data row
    
  • Insert a blank line in the result set

    Hi friends,

    SELECT * FROM EMPLOYEES ORDER BY DEPARTMENT_ID;

    As a result of the foregoing, I need to INSERT a blank line in the result for each department_id. for example, the result should resemble the following:

    EMP_ID - NAME - SALARY - DEPARTMENT_ID
    101 - Albert - 10 000 - 10
    102 - Benjamin - 8 000 - 10

    103 - Chitra - 10 500 - 20
    104 - David - 4 500-20
    105 - Elango - 6 000 - 20

    106 - faye - 6 000 - 30
    107 - Ganga - 9 000 - 30

    etc.

    I don't want to insert into the table. I need a blank line just on the screen.

    Thanks in advance.

    Published by: James on March 8, 2010 11:37

    Something like this->

    satyaki>
    satyaki>select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>
    satyaki>select m.empno,
      2         m.ename,
      3         m.sal,
      4         case
      5           when sal is null
      6           and  empno is null
      7           and  ename is null then
      8             null
      9         else
     10           m.deptno
     11         end deptno
     12  from (
     13        select k.empno,
     14              k.ename,
     15              k.sal,
     16              k.deptno
     17        from (
     18                select empno,
     19                             ename,
     20                             sal,
     21                             deptno
     22                from emp
     23            ) k
     24        union all
     25        select t.*
     26        from (
     27                select distinct null empno, null ename, null sal, deptno
     28                from emp
     29            ) t
     30        order by 4
     31      ) m;
    
         EMPNO ENAME             SAL     DEPTNO
    ---------- ---------- ---------- ----------
          7782 CLARK            2450         10
          7839 KING             5000         10
          7934 MILLER           1300         10
    
          7566 JONES            2975         20
          7369 SMITH             800         20
    
          7902 FORD             3000         20
          7876 ADAMS            1100         20
          7788 SCOTT            3000         20
    
         EMPNO ENAME             SAL     DEPTNO
    ---------- ---------- ---------- ----------
          7900 JAMES             950         30
          7499 ALLEN            1600         30
          7844 TURNER           1500         30
          7654 MARTIN           1250         30
          7521 WARD             1250         30
          7698 BLAKE            2850         30
    
    17 rows selected.
    
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    

    Kind regards.

    LOULOU.

  • Word RTF Tem [plate - insert a blank line in the loop

    I'm entering my template like this XML data (this is just an example of dumbed down):

    <? XML version = "1.0"? >

    < LABEL_TEST >

    < LIST_G_TEST >

    < G_LABEL_HEADER >

    < NAME > Parent 1 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Kid 1 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Parent 2 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Parent 3 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > 4 Parent < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Kid 4 < / NAME >

    < / G_LABEL_HEADER >

    < / LIST_G_TEST >

    < / LABEL_TEST >

    In summary, I have a list of Parents, and if they have a child, the name of their children is below. Not all parents have children.

    If the data is a bit like this:

    Name of the parent

    Name of the child

    Name of the parent

    Name of the parent

    Name of the parent

    Name of the child

    When I loop data in my RTF model, I want to be able to insert a blank line before all of the lines 'Parent '. A bit like this:

    Name of the parent

    Name of the child

    Name of the parent

    Name of the parent

    Name of the parent

    Name of the child

    I tried to do this by adding an empty xml tag in the list, like this:

    <? XML version = "1.0"? >

    < LABEL_TEST >

    < LIST_G_TEST >

    < G_LABEL_HEADER >

    < NAME > Parent 1 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Kid 1 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Parent 2 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Parent 3 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > 4 Parent < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Kid 4 < / NAME >

    < / G_LABEL_HEADER >

    < / LIST_G_TEST >

    < / LABEL_TEST >

    But that doesn't seem to work.

    Manny

    I found a solution that works very well.

    I added a new XML field to my data called .  In my model, this field is inserted in the line, but in a location where there is no data being printed. And it is formatted as white text, so that it basically just does not appear.

    So essentially, it's what I have now:

    Parent 1

    .

    Child 1

    .

    .

    Parent 2

    .

    .

    Parent 3

    .

    .

    Mother 4

    .

    Child 4

    .

    If the data is a bit like this:

    The name of the parent.

    The name of the child.

    .

    The name of the parent.

    .

    The name of the parent.

    .

    The name of the parent.

    The name of the child.

    When I loop data in my RTF model, the '. ' is a white text, then I get this:

    Name of the parent

    Name of the child

    Name of the parent

    Name of the parent

    Name of the parent

    Name of the child

  • OfficeJet Pro 8600 longer print a blank page after each job

    Well, maybe not always, but certainly more often and each time this morning. It begins eating at my nerves.

    How is the printer connected? (USB, ethernet, wireless)

    If USB:

    Disconnect both ends of the USB cable

    Unplug the power to the printer cable

    * Restart the PC

    * After the PC has completely powered up, then plug printer back to

    * Connect the USB cable to the printer and PC

    If network:

    * Unplug the router all-in-on

    * Wait 30 seconds

    * Plug the router back to

    * Once the router has propelled upwards, restart the PC

    * Unplug the printer while on

    * Wait 30 seconds

    * Plug the printer back to

    Also, have you tried running printing HP and doctor Scan?  It is an automated tool of troubleshooting provided by HP.  The tool can be found here.

    It is also possible that some of the internal software of the printer is hung up.  I will send the information to reset this printer to a factory State.  Please check your Inbox for messages.  Before taking these steps, please read Bob_Headrick wire on the printer reset, found here.  I hope this helps.

  • How to insert a new line in a table?

    I have a table of basic bit of lines and columns.

    In excel if I want to insert a blank line in the Middle, I just click right and do it.

    In DW, I am at a loss what to do. Thank you.

    It is very similar to the DW.  Right-click in a cell, and then click Table-> Insert a row or a column.  There is options to add several lines above or below.

  • Microsoft Media player error message tells me to insert a blank disc

    original title: Microsoft Media player error message

    I tried to burn music from my playlist on the media player on a blank CD and it tells me to insert a blank disc after that I already have, and then says that the program will start once it recognizes the blank test. How can I get it to work.

    Hello

    Thanks for asking!

    1. who is the operating system installed on your system?

    2. did you of recent changes to the system before the show?

    3. do you get an error message when you try to burn the disc?

    Method:

    Follow the indicated link and follow the steps. Check if it helps.

    Open the troubleshooting Windows Media Player settings Troubleshooter

    http://Windows.Microsoft.com/en-us/Windows7/open-the-Windows-Media-Player-settings-Troubleshooter

    Burn a CD or DVD in Windows Media Player: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows7/burn-a-CD-or-DVD-in-Windows-Media-Player-frequently-asked-questions

    Answer with the results, I would be happy to help you further.

  • Extra blank line inserted after the page break

    Hello

    I currently have problems with alignment using templates in BI Publisher.
    I am trying to create a model that will print on a pre-printed form.
    Each group in the State should be separated by page, so the Group has a <? split-of-page-break:? > before <? end-for-each? >.
    However, when the next page begins, there is a blank line inserted. This messes up the alignment in total.

    Code looks like this:
    <? for-each-group: G_Document; / DOCUMENT? > <? sorting: current-group () / DOCUMENT; ' ascending '; data-type = "text"? > <? for - each:current-group()? >
    -INSERT table MODEL HERE-
    <? split-of-page-break:? > <? end-for-each? >

    Output is like this:

    (Page1) < TABLE MODEL >
    Jump to Page <>
    (Page 2) < new line >
    < TABLE MODEL >
    Jump to Page <>
    (Page 3) < new line >
    < TABLE MODEL >
    Jump to Page <>
    ...

    I found this old thread Split-of-Page-Break insert extra line that has exactly the same problem, however, I tried all the proposed solutions, even the last one, and I still have the problem.
    Any help would be greatly appreciated.

    Kind regards
    Jovee

    If your issue is resolved can you please close the message and give me a few points.

  • Create a trigger that send mail with attachment after insertion of a line in Oracle APEX

    I want to create an insert after trigger on a table that is to send a mail with an attachment. Here is my code.

    CREATE OR REPLACE TRIGGER tr_feedback

    AFTER INSERT on REVIEWS

    FOR EACH LINE

    DECLARE

    l_id NUMBER;

    BEGIN

    l_id: = APEX_MAIL. SEND)

                    p_to        => ' [email protected] ',

    P_FROM = >: NEW. E-mail

    p_subj = >: NEW. Object

    p_body = > "Please see the attachment."

    p_body_html = > ' review of < b > please < /b > the attachment ")

    APEX_MAIL. ADD_ATTACHMENT (p_mail_id = > l_id,)

    p_attachment = >: NEW. FILE,

    p_filename = >: NEW. FILE NAME,

    p_mime_type = >: NEW. MIME);

    END;

    But when I insert data, I get the following error:

    ORA-20022: Null value provided for the parameter p_filename.

    ORA-06512: at "APEX_040200.WWV_FLOW_MAIL", line 1070

    ORA-06512: at "APEX_040200.WWV_FLOW_MAIL_API", line 141

    ORA-06512: at "TR_FEEDBACK", line 11

    ORA-04088: error during execution of trigger 'TR_FEEDBACK '.

    Now, how can I fix that? Thanks in advance.

    Agree with the above.  Triggers (ab) should not be used in this way.  Nontransactional process should not be based on a transactional trigger.  These processes are part of the business logic and should be at the level of the company of codification (Summit, you can add a process to be executed once the completed insertion)

  • SQL query to search for the line that contains the identifier for each consecutive group

    Hello

    I'm on 11.2.0.3 Enterprise Edition.

    I have a strange request here - do not know if this is possible without going to procedure...

    Given these data of the sample:

    create table test_status (
      status varchar2(10),
      revision_id number,
      revision_timestamp timestamp);
    
    insert into test_status values ('PROPOSED', 1, systimestamp);
    insert into test_status values ('PROPOSED', 2, systimestamp);
    insert into test_status values ('PROPOSED', 3, systimestamp);
    insert into test_status values ('ACTIVE', 4, systimestamp);
    insert into test_status values ('ACTIVE', 5, systimestamp);
    insert into test_status values ('PROPOSED', 6, systimestamp);
    insert into test_status values ('PROPOSED', 7, systimestamp);
    insert into test_status values ('ACTIVE', 8, systimestamp);
    insert into test_status values ('ACTIVE', 9, systimestamp);
    insert into test_status values ('FINISHED', 10, systimestamp);
    insert into test_status values ('FINISHED', 11, systimestamp);
    insert into test_status values ('FINISHED', 12, systimestamp);
    

    Gives me:

    SQL> select *
      2  from test_status
      3  order by revision_id;
    
    
    STATUS     REVISION_ID REVISION_TIMESTAMP
    ---------- ----------- -----------------------------
    PROPOSED             1 25-SEP-14 04.49.47.954000 PM
    PROPOSED             2 25-SEP-14 04.49.47.962000 PM
    PROPOSED             3 25-SEP-14 04.49.47.966000 PM
    ACTIVE               4 25-SEP-14 04.49.47.969000 PM
    ACTIVE               5 25-SEP-14 04.49.47.972000 PM
    PROPOSED             6 25-SEP-14 04.49.47.976000 PM
    PROPOSED             7 25-SEP-14 04.49.47.979000 PM
    ACTIVE               8 25-SEP-14 04.49.47.982000 PM
    ACTIVE               9 25-SEP-14 04.49.47.987000 PM
    FINISHED            10 25-SEP-14 04.49.47.991000 PM
    FINISHED            11 25-SEP-14 04.49.47.996000 PM
    FINISHED            12 25-SEP-14 04.49.48.000000 PM
    
    
    12 rows selected.
    ws selected.
    

    I want to get this result:

    STATUS     REVISION_ID REVISION_TIMESTAMP
    ---------- ----------- ----------------------------
    PROPOSED             3 25-SEP-14 04.49.47.966000 PM
    ACTIVE               5 25-SEP-14 04.49.47.972000 PM
    PROPOSED             7 25-SEP-14 04.49.47.979000 PM
    ACTIVE               9 25-SEP-14 04.49.47.987000 PM
    FINISHED            12 25-SEP-14 04.49.48.000000 PM
    

    Then query the table ordered by Revision_Id, I would get the line containing the highest revision for each consecutive group of status values.  I am able to get the line containing the highest revision for each separate status, value, but I can't deal with the scenario where a state value reappears later.  In the case of the real world, it is a workflow and I need to take into account the fact that an element through the workflow may be redirected to the back front she proceeds forward again.

    Hope it makes sense.

    Thank you

    John

    Hi, John,.

    John OToole (Dublin) wrote:

    Hello

    I'm on 11.2.0.3 Enterprise Edition.

    I have a strange request here - do not know if this is possible without going to procedure...

    ...

    Do not no stinkin' procedure:

    WITH got_grp_id AS

    (

    SELECT the status, revision_id, revision_timestamp

    ROW_NUMBER () OVER (ORDER BY revision_id)

    -ROW_NUMBER () (PARTITION STATUS

    ORDER BY revision_id

    ) AS grp_id

    OF test_status

    )

    SELECT status

    MAX (revision_id) AS revision_id

    MAX (revision_timestamp) DUNGEON (DENSE_RANK LAST ORDER BY revision_id)

    AS revision_timestamp

    OF got_grp_id

    GROUP BY status, grp_id

    ORDER BY revision_id

    ;

    For an explanation of the technique of Difference sets used here, see

    Analytic Question lag and lead and/or

    Re: Ranking of queries

  • queue a file by adding spaces after each line

    Hello

    I am the result of a sql queue in a csv file in the linux operating system. But the file generates a lot of blank lines after each line. How can this be eliminated in queue

    Thanks in advance

    SAS

    By default, SQL * more spool empty right pads each LINESIZE value line. Add

    SET TRIMSPOOL ON

    to your script.

    SY.

  • Introduce the empty line after each subtotal

    I want to add a blank line after each subtotal for readability. I thought that Char (13) would do the trick. You have any ideas on how to achieve this?

    Thank you
    Dinesh.

    In the PivotTable, you can do it in double layer on the column that you are dissociation on. Then in the ownership of the sum of the column in double, specify label only. Hide duplicated columns.

    HTH
    -Prakash

  • Line does not come after each row of the list

    Hello

    I show a list in my current application. In the list, I paint a line after each line. Just a line of string, I add in each line. Now when I'm checking the list, on some devices, lines are coming. As in Bold 9790, after each line, a line is added. But in the Torch 9810 and curved 9320, line is not there. I don't get why this different behavior for different devices.

    Can someone please help.

    Here is my code:

    public class ListCallBack implements ListFieldCallback{
    
            public void drawListRow(ListField listField, Graphics graphics, int index,
                    int y, int width) {
    
                String text = "xxxxxxx";
                graphics.setFont(FONT_FAMILY_1_SF_AS_08);
                graphics.drawText(text, 10, y, DrawStyle.ELLIPSIS, width);
    
                if (index != 0) {
                    graphics.setColor(Color.BLACK);
                    graphics.drawLine(0, y-12, width, y-12);
                }
            }
    
            public Object get(ListField listField, int index) {
                // TODO Auto-generated method stub
                return mAccounts[index];
            }
    
            public int getPreferredWidth(ListField listField) {
                // TODO Auto-generated method stub
                return screenWidth;
            }
    
            public int getPreferredHeight() {
                return getContentHeight();
            }
    
            public int indexOfList(ListField listField, String prefix, int start) {
                // TODO Auto-generated method stub
                return listField.getSelectedIndex();
            }
    
            }
    }
    

    Thank you...

    The best result I wanted to say, variable height from station to station. So currently I use the line height and made changes accordingly.

    Here is my Code:

     Font f = FONT_FAMILY_1_SF_AS_08;
                graphics.setFont(f);
                int h = f.getHeight();
                int height = (listField.getRowHeight() - h)/2 ;
                y += height;
                graphics.drawText(text, 10, y, DrawStyle.ELLIPSIS, width);
                if (index != 0) {
                    graphics.setColor(Color.BLACK);
                    graphics.drawLine(0, y - height + 1 , width, y - height + 1);
                }
    

    It worked properly. Thanks a lot Peter and Simon.

  • gray line after each line of list field

    Hi friends,

    I would like to draw a gray line after each line of listField I use folowing d

    graphics.setColor (Color.LIGHTGREY);

    graphics.drawLine (0, y, Graphics.getScreenWidth (), y);

    then the line is gray (the color of the text)

    then as the then-jeutiliser

    graphics.setColor (Color.LIGHTGREY);

    graphics.drawLine (0, y, Graphics.getScreenWidth (), y);

    graphics.setColor (Color.BLACK);

    It works, but, more early when the update comes to rowing of the color of the text will change to white but now always the text is black

    So, how can I draw a gray line after each listfield rw without affecting the texts

    You must save the original color and reset it after drawing like that.

    int origcolor = graphics.getColor(); 
    
    graphics.setColor(Color.LIGHTGREY);
    graphics.drawLine(0,y,Graphics.getScreenWidth(),y);
    
    graphics.setColor(origcolor);
    
  • BlackBerry smartphone how to force a blank line after signature

    Hi all!

    I'm trying to force a blank line after the signature "sent from Blackberry. I know how to change the signature, but I do not know how to do a blank line at the end.  When I hit the Enter key, it takes just the cursor to the next field.

    I'm sure it's something simple, but I can't understand it.

    TIA!

    I wrote my signature as I wanted, using line breaks, I typed up in memopad as I wanted, then copied/pasted in the signature field. Worked perfectly.

    Or type it upward in email on computer and send it to your BlackBerry and copy and paste from there.

    According to what is easier or more convienent for you.

Maybe you are looking for

  • WRT1900ACS slow down with WPA2-mixed use

    For other people, I'm sure are going to face this as well: At least the current firmware (1.0.0.168229), my experience has been that turning on WPA2 Personal only idle speeds of wireless for my Galaxy 6 ten times.  For example,. WPA2 Personal only: 4

  • DeskJet Ink Advantage - the new generation of affordable printing

    See the link below for more information on Ink Advantage printers http://h41112.www4.HP.com/campaign/ink-advantage/EMEA/en/originalhpink.html DeskJet Ink Advantage 2515 DeskJet Ink Advantage 3515 DeskJet Ink Advantage 3525 DeskJet Ink Advantage 5525

  • Reset of device blackBerry Smartphones

    Is it possible to reset the phone as it was?

  • Install Windows 8 x 86 (32 bit) on netbook. He turns?

    System information: Intel Atom 1.66 GHz, 1 core 2 son with Hyper-Threading (x86architecture, pineview N450) 2 GB OF DDR3 SDRAM MEMORY 256 MB Intel HD 3400 series graphic 250 GB of available hard disk space Maximum screen resolution is 1024 x 600 You

  • Hello, I can't create a new folder under windows 7.

    Options are still their and when I type mkdir folder_name in the command prompt it creates a folder, but when I press on the new folder buttons, it does nothing. It does not matter where, not on the desktop or in others. By the way im running windows