INSERTing a blank row in the result set

Hi friends,
SELECT * FROM EMPLOYEES ORDER BY DEPARTMENT_ID;
In the result of the above, I need to INSERT a blank row in the result for each DEPARTMENT_ID. i.e., the result should look like 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 - Fathima - 6,000 - 30
107 - Ganga - 9,000 - 30
etc.
I don't want to insert into the table. Just in display I need a blank row.
Thanks in advance.
Edited by: Iniyavan on Mar 8, 2010 11:37 AM

Are you looking for this?
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>select * from emp;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
14 rows selected.
Elapsed: 00:00:00.00
satyaki>
satyaki>break on deptno
satyaki>
satyaki>
satyaki>select empno,
  2            ename,
  3            sal,
  4            deptno
  5     from emp
  6     order by deptno;
     EMPNO ENAME             SAL     DEPTNO
      7782 CLARK            2450         10
      7839 KING             5000
      7934 MILLER           1300
      7566 JONES            2975         20
      7902 FORD             3000
      7876 ADAMS            1100
      7369 SMITH             800
      7788 SCOTT            3000
      7521 WARD             1250         30
      7844 TURNER           1500
      7499 ALLEN            1600
     EMPNO ENAME             SAL     DEPTNO
      7900 JAMES             950         30
      7698 BLAKE            2850
      7654 MARTIN           1250
14 rows selected.
Elapsed: 00:00:00.04
satyaki>
satyaki>Regards.
Satyaki De.

Similar Messages

  • Insert a Blank Column in the Results Area of a Workbook

    Is it possible to insert a blank column in the results area of a WORKBOOK that does not get affected by free characteristic drill down or refreshing of the corresponding query?  The current workbook looks like follows
    Column A - Characteristic1
    Column B - Characteristic2
    Column C - KeyFigure1
    Column D - KeyFigure2
    Column E - KeyFigure3
    Column F - KeyFigure4
    The requirement is that the user wants to enter some estimates between Column B and Column C and Column D and Column E as follows
    Column A - Characteristic1
    Column B - Characteristic2
    Column C - USER ENTRY
    Column D - KeyFigure1
    Column E - KeyFigure2
    Column F - USER ENTRY
    Column G - KeyFigure3
    Column H - KeyFigure4
    Column I - CALCULATIONS BASED ON USER ENTRY
    First I tried to split the results area and save the workbook.  But when the query is refreshed then the entire results area gets back in one piece.  I succeeded partially by having a key figure with no possible output (i.e., restricting a non-existent value on a characteristic).  Again in here, whatever user inputs will get wiped out with the drill down.  Does any one have any pointers?  Thanks.
    IS

    Hi IS,
    As a nearly workaround I can suppose to do the following.
    Create two identical requests.
    In the first one hide the columns to the right from your intended new user column. In the second one - hide columns to left.
    Knowing the columns number to be shown in each request you can place both request in the same row, but in different columns taking into account that between result areas should be one (or more) additional column.
    Data entered by a user will not be wiped out during query refresh or drilldown. Of course, these user data will not conform drilldown operations. So, it is not 100% solution you want.
    Another possibility, very hard to implement (if feasible at all), is to write VB code that will monitor user action and will keep data entered by a user somewhere in another sheet and restore them in proper cells after user action (drilldown). But I don't think such coding worth it.   
    Best regards,
    Eugene

  • How to add a dummy row in the result set of a SELECT statement.

    Hello Everyone -
    I have requirment to add a dummy row in the result set of a SELECT statement.
    For e.g. lets say there is a table Payment having following colums:
    Payment_id number
    status varchar2(10)
    amount number
    payment_date date
    so here is the data :-
    Payment_id Status Amount payment_date
    1 Applied 100 12/07/2008
    2 Reversed 200 01/ 06/2009
    3 Applied 300 01/ 07/2009
    Here is my SQL
    Select * form payment where payment_date >= 01/01/2009
    Output will be
    2 Reversed 200 01/ 06/2009
    3 Applied 300 01/ 07/2009
    My desired output is below
    2 Reversed 200 01/ 06/2009
    3 Applied 300 01/ 07/2009
    2 Reversed -200 01/ 06/2009 ------(Dummy Row)
    Thrid row here is the dummy row which I want to add when status is "Reversed"
    I would be very thankful for any kind of help in this regard ...
    Thanks,
    Gaurav

    Cartesion joining against a dummy table is a useful method of creating a dummy row:
    with my_tab as (select 1 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
                    select 1 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 1 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/05/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 4 Payment_id, 'Reversed' Status, -400 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 5 Payment_id, 'Applied' Status, 500 Amount, to_date('01/07/2009', 'mm/dd/yyyy') payment_date from dual),
                    --- end of mimicking your table
          dummy as (select 'Reversed' col1, 1 rn from dual union all
                    select 'Reversed' col1, 2 rn from dual)
    select mt.cust_id,
           mt.payment_id,
           mt.status,
           decode(dummy.rn, 2, -1*mt.amount, mt.amount) amount,
           mt.payment_date
    from   my_tab mt,
           dummy
    where  mt.status = dummy.col1 (+)
    order by mt.cust_id, mt.payment_id, dummy.rn nulls first;
    CUST_ID     PAYMENT_ID     STATUS     AMOUNT     PAYMENT_DATE
    1     1     Applied     100     07/12/2008
    1     2     Reversed     200     06/01/2009
    1     2     Reversed     -200     06/01/2009
    1     3     Applied     300     06/01/2009
    2     1     Applied     100     07/12/2008
    2     2     Reversed     200     05/01/2009
    2     2     Reversed     -200     05/01/2009
    2     3     Applied     300     06/01/2009
    2     4     Reversed     -400     06/01/2009
    2     4     Reversed     400     06/01/2009
    2     5     Applied     500     07/01/2009Edited by: Boneist on 07-Jan-2009 23:10
    NB. You may have to mess around with the ordering if that's not come back in the order you wanted. You didn't mention what the rules were for any expected ordering though, so I've made up my own *{;-)
    Also, I added an identifier (cust_id) to differentiate between different sets of payments, since that's usually the case. Remove that if it's not applicable for your case.

  • How to exclude the XML declaration from each row of the result set?

    Hi,
    I have a table with an XMLTYPE column and would like to SELECT a set of rows. How can I exclude the XML declaration from each row in the result set? My query currently looks like this, I'm executing it through Spring JDBC:
    SELECT XMLSerialize(CONTENT t1.xmltext) FROM myschema.event t1 WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e") ORDER BY t1.time DESC
    After selecting, in my application I convert each row into a String and concatenate all rows into one big string in order to parse it into a DOM model. I get a parser exception (org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed) because there are multiple XML declarations in my big string. Of course, I could manually check the String of each row whether it starts with the XML declaration, but it would be nicer if I could instruct the DB not to add it in the first place. Is there a way?
    Thanks!
    -- Daniela

    Hi,
    A couple of options I can think of :
    SELECT XMLSerialize(CONTENT
    XMLtransform(t1.xmltext,
      xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes"/> 
    <xsl:template match="/"><xsl:copy-of select="*"/></xsl:template>
    </xsl:stylesheet>')
    FROM myschema.event t1
    WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e")
    ORDER BY t1.time DESC
    ;or simply,
    SELECT XMLSerialize(CONTENT
      extract(t1.xmltext,'/')
    FROM myschema.event t1
    WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e")
    ORDER BY t1.time DESC
    ;

  • Getting specific row of the result set.

    table: employee
    empno           number(20)
    ssan           varchar2(9)
    date_time_stamp date
    My Sql gets all the empno where ssan and date_time_stamp are equal.
    However I need previous row from max(empno) where ssan & date_time_stamp are equal.
    For eg:
    empno     ssan           date_time_stamp
    100     123456789     01-FEB-2004
    101     000000000     02-FEB-2004
    102     123456789     01-FEB-2004
    103     123456789     01-FEB-2004
    105     123456789     01-FEB-2004
    I need row with empno = 103.
    My current sql fetches all rows for particular ssan where ssan and date time stamp are equal that fetches all empno for particular ssan and date time stamp. I want the max(empno) -1 (previous row of the result set).
    Here is my sql:
    select empno,ssan,date_time_stamp
    from employee e
    where date_time_stamp in (select date_time_stamp from employee where e.ssan = ssan)
    order by empno,ssan;
    The above sql will fetch
    empno     ssan           date_time_stamp
    100     123456789     01-FEB-2004
    102     123456789     01-FEB-2004
    103     123456789     01-FEB-2004 ---&gt; I need this row, previous row from max(empno) where ssan and date time
    stamp are matching.
    105     123456789     01-FEB-2004
    101     000000000     02-FEB-2004

    If I understand correctly, you want the second highest empno for each unique combination of ssan and date_time_stamp. If so, given
    SQL> SELECT * FROM employee;
         EMPNO SSAN      DATE_TIME_S
           102 123456789 01-feb-2004
           103 123456789 01-feb-2004
           105 123456789 01-feb-2004
           100 123456678 01-feb-2004
           102 123456678 01-feb-2004
           103 123456678 01-feb-2004
           101 000000000 02-feb-2004
           105 123456678 01-feb-2004
           100 123456678 02-feb-2004
           102 123456678 02-feb-2004
           103 123456678 02-feb-2004
           105 123456678 02-feb-2004
           100 123456789 01-feb-2004Then something like this should do it.
    SQL> SELECT empno,ssan,date_time_stamp
      2  FROM (SELECT empno,ssan,date_time_stamp,
      3               RANK() OVER (PARTITION BY ssan,date_time_stamp
      4                            ORDER BY empno DESC) rk
      5        FROM employee)
      6* WHERE rk = 2;
         EMPNO SSAN      DATE_TIME_S
           103 123456678 01-feb-2004
           103 123456678 02-feb-2004
           103 123456789 01-feb-2004HTH
    John

  • Inserting row in the result set

    Hi
    need to insert a row in resultset when previous row typ=c and next row typ=p then need to insert one row in between typ c and p with typ =s see the #temp_result table for result expected
    --drop table temp1
    --drop table temp1_result
    --presently data:-
    create table temp1
    (id int,
    ord int,
    typ varchar(2),
    dt date)
    insert into temp1 values (101, 1, 'c', '2001-10-01')
    insert into temp1 values (101, 2, 'p', '2001-11-11')
    insert into temp1 values (102, 1, 'c', '2002-10-01')
    insert into temp1 values (102, 2, 'p', '2002-11-01')
    insert into temp1 values (102, 3, 'p', '2002-12-01')
    insert into temp1 values (103, 1, 'c', '2003-10-01')
    insert into temp1 values (103, 2, 'p', '2003-11-01')
    insert into temp1 values (104, 1, 'c', '2004-10-01')
    insert into temp1 values (104, 2, 'c', '2004-11-01')
    insert into temp1 values (104, 3, 'p', '2004-12-01')
    insert into temp1 values (105, 1, 'c', '2005-10-01')
    insert into temp1 values (105, 2, 'p', '2005-11-01')
    insert into temp1 values (105, 3, 'c', '2005-12-01')
    insert into temp1 values (106, 1, 'c', '2006-08-01')
    insert into temp1 values (106, 2, 'p', '2006-09-01')
    insert into temp1 values (106, 3, 'c', '2006-10-01')
    insert into temp1 values (106, 4, 'p', '2006-11-01')
    insert into temp1 values (106, 5, 'p', '2006-12-01')
    select * from temp1
    order by id, ord
    --result expected:-
    create table temp1_result
    (id int,
    ord int,
    typ varchar(2),
    dt date)
    insert into temp1_result values (101, 1, 'c', '2001-10-01')
    insert into temp1_result values (101, 2, 's', '')
    insert into temp1_result values (101, 3, 'p', '2001-11-11')
    insert into temp1_result values (102, 1, 'c', '2002-10-01')
    insert into temp1_result values (102, 2, 's', '')
    insert into temp1_result values (102, 3, 'p', '2002-11-01')
    insert into temp1_result values (102, 4, 'p', '2002-12-01')
    insert into temp1_result values (103, 1, 'c', '2003-10-01')
    insert into temp1_result values (103, 2, 's', '')
    insert into temp1_result values (103, 3, 'p', '2003-11-01')
    insert into temp1_result values (104, 1, 'c', '2004-10-01')
    insert into temp1_result values (104, 2, 'c', '2004-11-01')
    insert into temp1_result values (104, 3, 's', '')
    insert into temp1_result values (104, 4, 'p', '2004-12-01')
    insert into temp1_result values (105, 1, 'c', '2005-10-01')
    insert into temp1_result values (105, 2, 's', '')
    insert into temp1_result values (105, 3, 'p', '2005-11-01')
    insert into temp1_result values (105, 4, 'c', '2005-12-01')
    insert into temp1_result values (106, 1, 'c', '2006-08-01')
    insert into temp1_result values (106, 2, 's', '')
    insert into temp1_result values (106, 3, 'p', '2006-09-01')
    insert into temp1_result values (106, 4, 'c', '2006-10-01')
    insert into temp1_result values (106, 5, 's', '')
    insert into temp1_result values (106, 6, 'p', '2006-11-01')
    insert into temp1_result values (106, 7, 'p', '2006-12-01')
    select * from temp1_resultregards
    Edited by: @2**** on 31-Jan-2012 06:48

    Well, in an Oracle database, something like this...
    SQL> ed
    Wrote file afiedt.buf
      1  with temp as (select 101 as id, 1 as ord, 'c' as typ, date '2001-10-01' as dt from dual union all
      2                select 101, 2, 'p', date '2001-11-11' from dual union all
      3                select 102, 1, 'c', date '2002-10-01' from dual union all
      4                select 102, 2, 'p', date '2002-11-01' from dual union all
      5                select 102, 3, 'p', date '2002-12-01' from dual union all
      6                select 103, 1, 'c', date '2003-10-01' from dual union all
      7                select 103, 2, 'p', date '2003-11-01' from dual union all
      8                select 104, 1, 'c', date '2004-10-01' from dual union all
      9                select 104, 2, 'c', date '2004-11-01' from dual union all
    10                select 104, 3, 'p', date '2004-12-01' from dual union all
    11                select 105, 1, 'c', date '2005-10-01' from dual union all
    12                select 105, 2, 'p', date '2005-11-01' from dual union all
    13                select 105, 3, 'c', date '2005-12-01' from dual union all
    14                select 106, 1, 'c', date '2006-08-01' from dual union all
    15                select 106, 2, 'p', date '2006-09-01' from dual union all
    16                select 106, 3, 'c', date '2006-10-01' from dual union all
    17                select 106, 4, 'p', date '2006-11-01' from dual union all
    18                select 106, 5, 'p', date '2006-12-01' from dual)
    19  --
    20  -- end of test data
    21  --
    22  select id
    23        ,row_number() over (partition by id order by ord, typ) as ord
    24        ,typ
    25        ,dt
    26  from (
    27        select id
    28              ,ord
    29              ,case when rn = 2 and add_typ = 's' then add_typ else typ end as typ
    30              ,case when rn = 1 then dt else null end as dt
    31        from (
    32              select t.id, t.ord, t.typ, t.dt
    33                    ,case when typ = 'c' and lead(typ) over (partition by id order by ord) = 'p' then 's'
    34                     else null end as add_typ
    35              from   temp t
    36             ) x
    37             cross join (select rownum rn from dual connect by rownum <= 2)
    38        where not (rn = 2 and add_typ is null)
    39       )
    40* order by id, ord
    SQL> /
            ID        ORD T DT
           101          1 c 01-OCT-2001 00:00:00
           101          2 s
           101          3 p 11-NOV-2001 00:00:00
           102          1 c 01-OCT-2002 00:00:00
           102          2 s
           102          3 p 01-NOV-2002 00:00:00
           102          4 p 01-DEC-2002 00:00:00
           103          1 c 01-OCT-2003 00:00:00
           103          2 s
           103          3 p 01-NOV-2003 00:00:00
           104          1 c 01-OCT-2004 00:00:00
           104          2 c 01-NOV-2004 00:00:00
           104          3 s
           104          4 p 01-DEC-2004 00:00:00
           105          1 c 01-OCT-2005 00:00:00
           105          2 s
           105          3 p 01-NOV-2005 00:00:00
           105          4 c 01-DEC-2005 00:00:00
           106          1 c 01-AUG-2006 00:00:00
           106          2 s
           106          3 p 01-SEP-2006 00:00:00
           106          4 c 01-OCT-2006 00:00:00
           106          5 s
           106          6 p 01-NOV-2006 00:00:00
           106          7 p 01-DEC-2006 00:00:00
    25 rows selected.

  • OBIEE Answers does not display the result set of a report query

    Hi,
    We have a pivot table type of report in Oracle Business Intelligence Enterprise Edition v.10.1.3.3.2 Answers that has the following characteristics:
         3 Pages
         3 Sections , 4 Columns
         18363 Rows in the result set
    As per the NQQuery.log, the query for this report executes successfully resulting in 18363 rows. However, nothing comes up in the display on Answers. Moreover, no error is reported. The instanceconfig.xml file has the following setting:
    <PivotView>
         <CubeMaxRecords>30000</CubeMaxRecords>
         <CubeMaxPopulatedCells>300000</CubeMaxPopulatedCells>
    </PivotView>
    Even with these settings, Answers just returns a blank page - nothing is displayed in the name of the result set of the report query. Has anyone encountered this problem scenario before?
    Any help is much appreciated.
    Thanks,
    Piyush

    Hi Fiston / Pradeep,
    Thanks for your inputs. A few points to note:
    -> I am actually not getting any error message in answers or the NQQuery log. Moreover I am not getting any errors related to "query governor limit exceeding in cube generation" also.
    -> I have other pivot table type of reports in the same repository that work fine. In fact the report which has this issue even works sometimes - what actually is happening is that if I alter the number of sections from 3 to 4, then the result set changes from 14755 Rows to 18363 Rows and as per the NQQuery.log in both cases the query completes successfully. However, when the result set has 14755 rows, I get to see the output in Answers; however when the result set is 18636 rows, the Answers screen just goes blank and does not show any output or error. This makes me believe that there is some parameter in instanceconfig or the NQSconfig file - I have tried a lot of changes but nothing works !
    Any help is much appreciated.
    Best Regards,
    Piyush

  • How to pass one row of a result set to a cffunction?

    I can pass the entire result set of a query to a cffunction,
    but the function only needs one row.
    The code below is a syntax error, where "3" is array index
    notation for the third row of the result set.
    What is the correct way to pass one row of a result set to a
    cffunction?
    Thank you.

    iirc, cf does not allow one to reference and access a row of
    a resultset
    like that.
    you will have to create a structure/array that holds the data
    from
    specific query row and pass that to your function. looping
    over
    queryname.columnlist list will make it easier and not
    specific to any
    particular query. make it into another function that accepts
    a query and
    row number as arguments and returns a struct/array of that
    row data (or
    automatically passes it to another function).
    sample code for creating a structure of specific query row
    data:
    <cfset rowstruct = {}>
    <cfloop list="#queryname.columnlist#" index="col">
    <cfset rowstruct[col] = queryname[col][somerownumber]>
    </cfloop>
    <cfdump var="#rowstruct#">
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

  • How to insert a new row in the middle of an set of rows

    Hi
    How to insert a new  row in the middle of an set of rows ? and How to Reset the line id after the new row added ?
    Regards,
    Sudhir B.

    Hai,
    just try this,
    Instead of using omatrix.Addrow(1,-1) use like
    omatrix.AddRow( RowCount , Position)
    RowCount
    The number of rows to add (default is 1)
    Position
    The position of the new rows (0-based; default is -1, meaning append row to the end)
    After adding rows in matrix For, sno.
    for i=1 to omatrix.visualrowcount
    otext=omatrix.getcellspecific("columnid",i)  '--where columnid is the unique id of the sno column
    otext.value=i
    next i
    Hope this helps you.
    Thanks & Regards,
    Parvatha Solai.N

  • The result set that contain 10 rows always

    Hi all,
    I'm wondering if there is some way to produce the result set of a query in 10 rows always, in other word i run a query and i want that the result set in 10 row even if the query dosn't return any row.
    I need that row as a placeholder.
    thanks
    Francesco

    Happened to be GUI developer and try to take advantage of SQL,
    select * from (select rownum rn, e.* from emp e where rownum<11 and 1=2) e
    right join (select rownum rn from dual connect by rownum<11) t
    on t.rn=e.rn
    RN 
    EMPNO ENAME 
    JOB         
    MGR HIREDATE    
    SAL  
    COMM
    DEPTNO    
    RN
    5
    8
    3
    1
    2
    10
    6
    7
    4
    9
    10 rows selected.
    select * from (select rownum rn, e.* from emp e where rownum<11) e
    right join (select rownum rn from dual connect by rownum<11) t
    on t.rn=e.rn
    RN 
    EMPNO ENAME 
    JOB         
    MGR HIREDATE    
    SAL  
    COMM
    DEPTNO    
    RN
    1  
    7369 SMITH 
    CLERK      
    7902 17-DEC-80   
    800               
    20     
    1
    2  
    7499 ALLEN 
    SALESMAN   
    7698 20-FEB-81  
    1600   
    300    
    30     
    2
    3  
    7521 WARD  
    SALESMAN   
    7698 22-FEB-81  
    1250   
    500    
    30     
    3
    4  
    7566 JONES 
    MANAGER    
    7839 02-APR-81  
    2975               
    20     
    4
    5  
    7654 MARTIN
    SALESMAN   
    7698 28-SEP-81  
    1250  
    1400    
    30     
    5
    6  
    7698 BLAKE 
    MANAGER    
    7839 01-MAY-81  
    2850               
    30     
    6
    7  
    7782 CLARK 
    MANAGER    
    7839 09-JUN-81  
    2450     
    0    
    10     
    7
    8  
    7788 SCOTT 
    ANALYST    
    7566 19-APR-87  
    3000               
    20     
    8
    9  
    7839 KING  
    PRESIDENT       
    17-NOV-81  
    5000     
    0    
    10     
    9
    10  
    7844 TURNER
    SALESMAN   
    7698 08-SEP-81  
    1500     
    0    
    30    
    10
    10 rows selected.

  • Getting the first row of a result set

    I need to get the first row returned from a select query that looks like this:
    SELECT DISTINCT parm1 FROM table1 WHERE parm1 > 10 ORDER BY parm1
    Can someone please show me how to do this?
    Alex

    Because you're only getting one row you don't need to bother with a DISTINCT clause. You'll need to order your data first and then nab the first row from that result set.
    SELECT parm1
      FROM (SELECT   parm1
                FROM table1
               WHERE parm1 > 10
            ORDER BY parm1)
    WHERE ROWNUM <= 1;

  • Is column visibility based on the first page of the result set or the entire result set?

    I have tried, in vain, to play with the column visibility expression in my report. So where my Business Unit is "MC" or "FM", then I want to display column "HCFA Number"...otherwise hide it. If I run strictly for "MC"
    it works! If I run simply for "CO" it works! And doesn't show! But if I combine "CO" and "MC", it is hidden and I would expect it to be visible since "MC" is part of my entire report.
    Here's the expression I came up with for Column Visibility...
    =IIf((Fields!BUSINESS_UNIT.Value = "MC") OR
    (Fields!BUSINESS_UNIT.Value = "FM"),FALSE,TRUE)
    Am I missing something here or just being dense late on a Friday???
    Thanks for your review and am hopeful for a reply.

    Hi ITBobbyP,
    It seems you have add parameter based on the "Business Unit" which is multiple values and when you select the "CO,MC" the entire column "HCFA Number" is hide, but what you want is to hide the CO related "HCFA Number"
    and show the MC related "HCFA Number", right?
    The expression you are using to show/hide the column visibility will based on the current filtered entire result set. That is mean the entire column "HCFA Number" will be show when the result set contains "MC" or "FM"
    or both, otherwise, it will always hide.
    In your scenario, you can set the row visibility using the expression and you will get the result like below:
    You can set the visibility of the textbox "[HCFANumber]", but the CO related "HCFANumber" will be blank:
    If I have some misunderstanding, please try to provide more details information about the expect result you want.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • How to get the result set in batches

    I have a query which results into large data. This data i want to display in a group of 20. After every 20 records i want to add header and footer to it.
    Is it possible to get the result set data into batch of 20 ? means can i specify start and end index of query ?
    regards
    Manisha

    What I am saying is that a big query with lots of
    joins will probably be slow, and as such would be a
    ripe candidate for batching the responses, if it were
    not possible to speed/optimize it. Batching is nice
    to look at for the user, but is not a solution for
    performance problems. In essence it is irrelevant
    that it adds a little performance deficit, as it
    appears to be running a lot quicker, and gives more
    feedback to the user.Then let me say it again....
    - "Join" is a term that applies to a method of doing queries in the database....
    - Query 1 which uses a join and returns 15 rows
    - Query 2 which does not use a join and returns 1500 rows.
    Given the above then Query 1 will provide better overall performance for the system than Query 2 in a properly configured database.
    If it doesn't then the database is not set up correctly.
    And again this will be irrespective of whether the query is scrollable or not.

  • By which method,i can get  the no of rows in the record set?

    Does anyone help me that by which method,i can get the no of rows in the record set?
    now i use next() to check whether the next record is available or not?

    shashi_rajak wrote:
    under Practice Exercise #1 heading :
    there is a statement.
    "Now, the COUNT function does not need to retrieve all of the fields from the table (ie: employee_number, employee_name, and salary), but rather whenever the condition is met, it will retrieve the numeric value of 1. Thus, increasing the performance of the SQL statement."And have you ever tried it? Or do you simply blindly believe everything you read? And what sort of "authority" is "tech on the net"?
    P.S. A quick test on Oracle (and you must do each query at least twice throwing away the first result, as Oracle always caches things which will have an effect, and averaging the remaining attempts).
    count(*) -- 1 min 17 secs for 35,311,978 rows
    count(1) -- 1 min 19 secs for 35,311,978 rows
    Edit: And the table has 46 columns.

  • How to hide the all rows except the result row in a report?

    Hi Experts,
    We have a report in which the user is interested to see only the result rows and I need to HIDE the characteristics in the rows. I was successfull in doing the same for Key figures in columns using "Calculate single value as suppress result". But I am not finding a way out to hide the characteristics in the rows.
    If I move the characteristics in rows to Free characteristics, the result row is not getting dispalyed. Also, the characteristics are  used dynamically by the formulae in columns and hence i cant remove these characteristics from the query. . The user wants the query to contain only one characteristic in the row and the result row for the key figures in columns. The report currently displays Invoice level data for each customer and this needs to be eliminated and it should display the summarised  data for every customer. Please suggest how this can be accomplished
    Regards,
    Kavitha

    Moving the char to free char will show the equivalent of result.
    Your issue likely is that this breaks the calculations since you do want the calculations done at detail level.
    To achieve this, move your char to free char (say it is 0CUSTOMER).
    For the CKF/Formula, go to aggregation tab, set the exception aggregation as Total (or whatever it was in standard behavior) and specify reference characteristic (in this case 0CUSTOMER), also check the 'Before aggregation' if you have that checkbox there.
    This will ensure the calculation is done at detail level even though the char is not included in the rows.
    If you have multiple chars to be moved to free char but included in detailed calculation, you will need to build cascading CKFs (CKF1 with ref char1, CKF2 eq to CKF1 with exception aggr on ref char2...and so on).
    Added:
    I understand you do want 0CUSTOMER in there, but something else (let us say 0DOCNO) removed. Use 0DOCNO in place of 0CUSTOMER in the case described above.
    Edited by: Ajay Das on Aug 5, 2009 8:57 AM

Maybe you are looking for