Rank only summary rows from group by rollup

I would like to rank only the total rows generated by a group by rollup, but not rank the rows within each group by bucket. Furthermore, I'd like to order by rank in descending order and include the unranked rows within each group.
My query looks something like this:
select customer, month, sum (sell)
from sales
group by rollup (customer, month)
order by customer, month desc nulls first
The results look like:
customer     month     sum(sell)
<summary rowA>          1,200
custA          JAN     100
custA          FEB     100
custA          MAR     100
custA          DEC     100
<summary rowB>          600
custB          JAN     50
custB          FEB     50
custB          MAR     50
custB          DEC     50
What I would like to do is:
select dense_rank() over (order by sum(sell) desc <rollup rows only>) as rank,
     customer, month, sum (sell)
from sales
group by rollup (customer, month)
order by <summary row rank desc> customer, month desc nulls first
The results would look like:
rank     customer     month     sum(sell)
1     <summary rowA>          1,200
     custA          JAN     100
     custA          FEB     100
     custA          MAR     100
     custA          DEC     100
2     <summary rowB>          600
     custB          JAN     50
     custB          FEB     50
     custB          MAR     50
     custB          DEC     50
Any advice?
Thank you

Like this?
sql>
select decode(job,null,decode(deptno,null,null,dense_rank() over(order by lst desc)-1),null) rank,
       deptno,job,sm
from(
      select deptno,job,sm,last_value(sm) over(partition by deptno order by null ) lst
      from (
            select deptno,job,sum(sal) sm
            from emp
            group by rollup(deptno,job)));
RANK DEPTNO JOB SM
                   29025 
   20  CLERK  1900 
   20  MANAGER  2975 
1  20     10875 
   20  ANALYST  6000 
   30  CLERK  950 
   30  MANAGER  2850 
2  30     9400 
   30  SALESMAN  5600 
   10  CLERK  1300 
   10  MANAGER  2450 
   10  PRESIDENT  5000 
3  10     8750                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Advanced Datagrid - Summary Row without groupping

    I need to make a datagrid with a summary row on top of it. It
    works fine with the gropping tag inside of groupping collection.
    But i don't need groups - i need only summaries.
    When I white following code inside of Advanced - flex crashes
    and tell something like "cannot null blablala".
    quote:
    <mx:GroupingCollection id="smallMetricsDataProvider"
    source="{bigMetrics}">
    <mx:summaries>
    <mx:SummaryRow summaryPlacement="first">
    <mx:SummaryField dataField="@type" operation="COUNT"
    />
    <mx:SummaryField dataField="@budget"
    summaryFunction="MetricsUtils.varianceTotalCount" />
    <mx:SummaryField dataField="@raw"
    summaryFunction="MetricsUtils.varianceTotalCount" />
    </mx:SummaryRow>
    </mx:summaries>
    </mx:GroupingCollection>
    What can you advice 4 me?
    Thanks, Roman.

    Fine, I found a way how to do it, using renderprovider 4
    folder items with a null height =))).
    It's a hack, the bad hack, i hope it wold be improved...
    So, i have another problem - i want to get this summary
    values. How?
    Thanks, Roman.

  • How to remove only one row from the database using labview6.1

    using labview 6.1 I create a table with various rows and columns and store bulk of data's in them.,, what procedure should I follow to remove only one paticular row from the database? Help me out with an example please,,
    Thanking you in advance!

    Hi,
    If you have the database toolkit you can delete a row using just a SQL Query to "DB Tools Execute Query.VI"
    Example:
    DELETE FROM Table name Where SerialNum='Value' And Date='Value' And Time='Value'
    See also attached VI
    Best Regards
    Johan
    Attachments:
    Delete_a_row_in_a_database_table.vi ‏48 KB

  • SQL query that returns exclusive rows from groups

    I'm using modified scott/tiger data for this.
    I've got two tables
    DEPT_X
    DEPTNO     DNAME             LOC     CODE_ID     SUB_DEPTNO
    10     ACCOUNTING     NEW YORK 111     101
    10     SALES             ATWN      111     102
    10     SALES             BTWN      112     103
    20     RESEARCH     DALLAS      111     201
    20     RESEARCH     CTWN      111     202
    30     SALES             CHICAGO      111     301
    40     OPERATIONS     BOSTON      112     401and
    BI_PD
    CODE_ID     PD_TYPE     BI_TYPE
    111          -1
    112     -1     I want to write a query that joins the code_ids of the two tables and lists out either only the records from DEPT_X who's code_ids have a -1 in the PD_TYPE(112) column and none of the code_ids that have a -1 in the BI_TYPE(111) column for each department or if that department has code_ids for the BI_TYPE (111), list out those rows. So for Deptno 10 you'll only get the row with SUB_DEPTNO = 103. But if for that DEPTNO= 20 you'll get the rows for both SUB_DEPTNO = 201 and 202.
    So the result should look like
    DEPTNO   SUB_DEPTNO
    10          103
    20          201
    20          202
    30          301.
    Basically I just want rows from each department that have code_ids = 111 not to show up if there are code_ids = 112.
    What is the query to do this?
    Message was edited by:
    user623359
    Message was edited by:
    user623359
    Message was edited by:
    user623359
    Message was edited by:
    user623359
    Message was edited by:
    user623359

    One way could be:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> with dept_x as (
      2      select 10 deptno, 'ACCOUNTING' dname, 'NEW YORK' loc, 111 code_id, 101 sub_deptno from dual
    union all
      3      select 10, 'SALES', 'ATWN', 111, 102 from dual union all
      4      select 10, 'SALES', 'BTWN', 112, 103 from dual union all
      5      select 20, 'RESEARCH', 'DALLAS', 111, 201 from dual union all
      6      select 20, 'RESEARCH', 'CTWN', 111, 202 from dual union all
      7      select 30, 'SALES', 'CHICAGO', 111, 301 from dual union all
      8      select 40, 'OPERATIONS', 'BOSTON', 112, 401 from dual ),
      9  --
    10  bi_pd as(
    11      select 111 code_id, null pd_type, -1 bi_type from dual union all
    12      select 112, -1, null from dual),
    13  --
    14  t as(
    15      select a.deptno,a.sub_deptno from dept_x a, bi_pd b
    16      where a.code_id = b.code_id and b.pd_type = -1)
    17  --
    18  select a.deptno,a.sub_deptno
    19  from dept_x a, bi_pd b
    20  where a.code_id = b.code_id and b.bi_type = -1 and 
    21        (a.deptno) not in (select deptno from t)
    22  union
    23  select deptno,sub_deptno from t;
        DEPTNO SUB_DEPTNO
            10        103
            20        201
            20        202
            30        301
            40        401

  • Discoverer Summary Adviser and GROUP BY / ROLLUP

    Can anyone answer the following for me?
    1. Does the Discoverer Summary Adviser ever create materialized views using the new ROLLUP function, to create summaries that calculate all the subtotals along all hierarchies and dimensions?
    2. If the Discoverer Summary Adviser cannot create them using GROUP BY and ROLLUP, but I generated them manually or using OEM, would the Discoverer queries ever be eligable for query rewrite, as I presume the SQL generated by Discoverer doesn't use the GROUP BY / ROLLUP feature found in Oracle 9i?
    Any advice gratefully received.
    Mark

    Can anyone answer the following for me?
    1. Does the Discoverer Summary Adviser ever create materialized views using the new ROLLUP function, to create summaries that calculate all the subtotals along all hierarchies and dimensions?
    2. If the Discoverer Summary Adviser cannot create them using GROUP BY and ROLLUP, but I generated them manually or using OEM, would the Discoverer queries ever be eligable for query rewrite, as I presume the SQL generated by Discoverer doesn't use the GROUP BY / ROLLUP feature found in Oracle 9i?
    Any advice gratefully received.
    Mark

  • Selecting only one row from a query

    Hi,
    I am using database version 10.2.0.4.0
    I have 2 tables:
    artist(artistid, artistname, titleid)
    trans(transid, datesold, salesprice, titleid, artistid)
    This is what i used and got the below results.
    SELECT max(worksold) AS mostworksold
    FROM (
    SELECT artistname, COUNT(t.artistid) AS worksold
    FROM table.artist a, table.trans t
    WHERE a.artistid = t.artistid
    GROUP BY artistname
    MOSTWORKSOLD
    12
    However I also want to show the artist name who sold the most work. So i added artist name in the select, but the result came out very different.
    SELECT artistname, max(worksold) AS mostworksold
    FROM (
    SELECT artistname, COUNT(t.artistid) AS worksold
    FROM table.artist a, table.trans t
    WHERE a.artistid = t.artistid
    GROUP BY artistname
    group by artistname;
    ARTISTNAME MOSTWORKSOLD
    John 3
    Mary 4
    Alvin 9
    Trevor 5
    Jess 12
    What should I do to make it show only this?
    ARTISTNAME MOSTWORKSOLD
    Jess 12
    Regards,
    Keith
    Edited by: 963214 on Oct 5, 2012 10:12 AM
    Edited by: 963214 on Oct 5, 2012 10:40 AM

    try this... hope this helps...
    with xx as(
      select '1' as aid,'john' as anm from dual union all
      select '2' as aid,'mary' as anm from dual union all
      select '3' as aid,'alvin' as anm from dual union all
      select '4' as aid,'trevor' as anm from dual union all
      select '5' as aid,'jess' as anm from dual
    ), yy as(
      select '1' aid from dual union all
      select '2' aid from dual union all
      select '2' aid from dual union all
      select '3' aid from dual union all
      select '3' aid from dual union all
      select '3' aid from dual union all
      select '4' aid from dual union all
      select '4' aid from dual union all
      select '4' aid from dual union all
      select '4' aid from dual union all
      select '4' aid from dual union all
      select '5' aid from dual
    select x.* from
    (SELECT a.anm as nm, COUNT(t.aid) AS worksold
    FROM xx a, yy t
    WHERE a.aid = t.aid
    GROUP BY anm
    order by worksold desc) x
    where rownum = 1; gives
    trevor     5In 2 ^nd^ table, i've considered only 1 column which is actually used. Rest columns are unessential.
    Ranit B.
    Edited by: ranit B on Oct 6, 2012 12:20 AM

  • E-mail Body Displays Only 1 Row From Select

    Because APEX doesn't currently (easily) support attachments to e-mail, I've created a process to call the apex_mail.send procedure that then displays specific criteria in the body of the e-mail. This is gathered via a cursor, etc. The problem is, my query only returns 1 row and should return more. I know this because the select for the cursor is essentially the same criteria as I'm using for a report.
    My process is listed below.
    declare
    e_body_html CLOB;
    j_sql CLOB;
    cursor gather_usrs_cur
    is
    select Q_APEX_ID,
    USER_ID,
    Q_USER_TYPE,
    Q_FIRST,
    Q_LAST,
    C_PHONE,
    C_EMAIL,
    C_STATE
    from Q_AUDIT
    where MATCH = 'Y' and
    UPDT_ID is null and
    UPDT_TS is null and
    COMMENTS is null and
    Q_USER_TYPE = :P32_USER_TYPE;
    BEGIN
    e_body_html := 'This e-mail is being generated to inform you that there are users in your State who have had their BLANK access revoked,'||utl_tcp.crlf;
    e_body_html := e_body_html ||' but their access to the secured portions of BLANK is still active. Those users are: '||utl_tcp.crlf||utl_tcp.crlf;
    for usr_rec in gather_usrs_cur
    loop
    begin
    j_sql := usr_rec.user_id||' '||usr_rec.Q_first||' '||usr_rec.Q_last||' '||usr_rec.C_phone||' '||usr_rec.C_email||utl_tcp.crlf;
    j_sql := j_sql ||usr_rec.user_id||' '||usr_rec.Q_first||' '||usr_rec.Q_last||' '||usr_rec.C_phone||' '||usr_rec.C_email||utl_tcp.crlf;
    end;
    end loop;
    commit;
    apex_mail.send(
    P_TO => '[email protected]',
    P_FROM => '[email protected]',
    P_BODY => e_body_html||j_sql,
    P_SUBJ => 'Accounts Requiring Review');
    end;
    I've included the carriage returns and have also tried substituting the ||utl_tcp.crlf|| with ||char(13)|| and ||char(10)||, to no avail. The e-mail displays the body and one row of the select. Please let me know how I can get my entire results list to display. Thanks in advance for your response(s) and expertise.

    Jason,
    The for loop reset the j_sql in every iteration. It should be:
    j_sql := null;
    for usr_rec in gather_usrs_cur
    loop
    begin
    j_sql := j_sql||usr_rec.user_id||' '||usr_rec.Q_first||' '||usr_rec.Q_last||' '||usr_rec.C_phone||' '||usr_rec.C_email||utl_tcp.crlf;
    j_sql := j_sql ||usr_rec.user_id||' '||usr_rec.Q_first||' '||usr_rec.Q_last||' '||usr_rec.C_phone||' '||usr_rec.C_email||utl_tcp.crlf;
    end;
    end loop;Sima

  • Pick only one row from the repeated rows

    Oracle 10g r2 (10.2.0.5)
    I have a query/view, which returns the the reords as follows
    set colsep ||
    Name     ||     Address     ||        Zip
    abc123     || Ln1     || 123456
    bcd123     || Ln2     || NULL
    bcd123     || Null     || 45678
    efg123     || Ln0     || 96345
    efg123     || Ln0123     || Null
    efg123     || adr     || null
    the result set I need from the above is
    set colsep ||
    Name     ||     Address     ||        Zip
    abc123     || Ln1     || 123456
    bcd123     || Ln2     || NULL
    efg123     || Ln0     || 96345
    As you see that the first record on each repeated row sets are required
    Thanks,

    Hi,
    Using the aggregate FIRST (or LAST) function like that, there's no guarantee that all of the output values on the same row will come from the same row in the original table. To do that, you can use the analytic ROW_NUMBER function, like this:
    WITH     got_r_num     AS
         SELECT     name, address, zip, ...
         ,     ROW_NUMBER () OVER ( PARTITION BY  name
                                   ORDER BY          address
                             ,                zip
                           )      AS r_num
         FROM     table_x
    SELECT     name, address, zip, ...
    FROM     got_r_num
    WHERE     r_num     = 1
    ;This assumes the "first" row is the one with the first address (in alphabetic order), and, in the event of a tie, the one with the lowest zip (however "lowest" is defined for zip). You can specify any order you want in the analytic ORDER BY clause.
    I hope that answers your question.
    If not, what is your question? Use words other than those you've already used to describe what you want to do.
    Explain exactly what "first" means in this problem.Point out where the query above (or the one posted by Claytonian, if that seems closer) is getting the wrong results, and explain how you'd get the right results in those places.
    If necessary, post new sample data (either CREATE TABLE and INSERT statements, or a WITH clause, as Claytonian did) and the results you want from that data.

  • Abap logic not fetching multiple rows from master data table

    Hi
    I just noticed that my logic is fetching only 1 row from master data table.
    ProdHier table
    PRODHIERACHY            Level
    1000                                  1
    1000011000                      2
    10000110003333              3
    10000110004444              3
    '10000110005555              3*
    logic only fetches one row of level 3, I would like to fetch all level 3 rows.
    DATA: ITAB type table of /BI0/PPROD_HIER,
          wa like line of ITAB.
    Select * from /BI0/PPROD_HIER INTO wa where /BIC/ZPRODHTAS = 3.
    IF wa-PROD_HIER(10) = SOURCE_FIELDS-PRODH2.
         RESULT = wa-PROD_HIER.
         ELSEIF wa-PROD_HIER(5) = SOURCE_FIELDS-PRODH1.
         RESULT = wa-PROD_HIER.
    ENDIF.
    ENDSELECT.
    thanks

    Hi,,
    I have implemented the logic in end routine and it still reads only the first row.
    I am loading only PRODH1 and PROD2 but now I want to get all values of PRODH3 from the master data table.
    The first 5 values are PRODH1 and first 10 values belongs to PRODH2.
    Whenever PRODH2 = 1000011000 in source I should get the following values
    10000110001110
    10000110001120
    10000110001130
    I have multiple rows of 1000011000 so my result should be
      1000011000               10000110001110
      1000011000               10000110001120
      1000011000               10000110001130
    DATA: ITAB type table of /BI0/PPROD_HIER,
    wa like line of ITAB.
    data rp type _ty_s_TG_1.
    Select  * from /BI0/PPROD_HIER INTO table itab where /BIC/ZPRODHTAS = 3.
    LOOP AT RESULT_PACKAGE INTO rp.
    read table itab into wa with key PROD_HIER(5) = rp-PRODH1.
    IF sy-subrc EQ 0.
         rp-PRODH3 = wa-PROD_HIER.
         ELSE.
    read table itab into wa with key PROD_HIER(10) = rp-PRODH2.
    IF sy-subrc EQ 0.
         rp-PRODH3 = wa-PROD_HIER.
    ENDIF.
    ENDIF.
    MODIFY RESULT_PACKAGE FROM rp.
    ENDLOOP.
    Edited by: Bhat Vaidya on Sep 10, 2010 11:27 AM
    Edited by: Bhat Vaidya on Sep 10, 2010 11:37 AM

  • How can i select some row from multiple row in the same group of data

    I want to select some row from multiple row in the same group of data.
    ColumnA        
    Column B
    1                  OK
    1                   NG
    2                   NG
    2                          NG
    3                          OK
    3                          OK
    I want the row of group of
    ColumnA if  ColumnB contain even 'NG'
    row , select only one row which  Column B = 'NG'
    the result i want = 
    ColumnA         Column B
    1                         NG
    2                   NG
    3                          OK
    Thank you

    That's some awful explanation, but I think this is what you were driving at:
    DECLARE @forumTable TABLE (a INT, b CHAR(2))
    INSERT INTO @forumTable (a, b)
    VALUES
    (1, 'OK'),(1, 'NG'),
    (2, 'NG'),(2, 'NG'),
    (3, 'OK'),(3, 'OK')
    SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
    FROM @forumTable f
    LEFT OUTER JOIN @forumTable f2
    ON f.a = f2.a
    AND f.b <> f2.b
    GROUP BY f.a

  • How to Query the Summary Name from Custom Section Row Header Information

    I need a query that can help me retrieve the summary name from a custom section row header information.  We have a couple of Denorm tables that when the data is denormalized, the row_name field is only showing the denormalized alias name.  We would like to be able to pull the summary name from the row header information section?  How can we use the denorm alias name and join it to another table to find the associated summary name?

    The following query returns the row name as well as the denorm row name, for a given custom section, where we specify the custom section by the denorm table. You oculd do this in other ways, it just depends on how you want to retrieve the information. Is this what you are looking for?
    SELECT ml.Name [rowName], ml.langID, dr.NAME [denormRowName], dr.FKROWTEMPLATE, dt.GENERATED_TABLE_NAME
    FROM DENORM_CS_ROW dr
    inner join DENORM_CS_TABLE dt on dr.FK_DENORM_TABLE_ID = dt.ID
    inner join commonextendedattributeml ml on dr.FKROWTEMPLATE = ml.fkOwner
    where dt.NAME = 'myDenormTableName'

  • Grouping rows from a query

    Hi everyone!
    I want to know if it's posible to group the rows from a query into a unique row. Example:
    SELECT Field_1 FROM Table_1
    Returns the following fileds:
    Field_1
    A
    B
    C
    D
    I would want to modify my query so that the result obtained would be a single row containing all the others. In the previous example the result would be "ABCD".
    Thanks in advance. Best regards,

    -- For anyone who wants to test this,
    -- just copy this entire post as is,
    -- save it to a .sql file, then start that file.
    -- Before doing this,
    -- make sure that you don't already have
    -- a table named table_1 that would be dropped
    -- or a .sql file named query.sql that would be overwritten.
    -- If you do, then change the names below to avoid any conflicts.
    -- In order to understand what the code is doing,
    -- please read all of the comments included in this file,
    -- as not everything is displayed when you run it.
    -- I have gone into great detail with this
    -- because I have posted similar things before
    -- and a lot of people have total missed the fact
    -- that it is not a static query,
    -- that the results are dependent upon the number of rows,
    -- and that it works for any number of rows,
    -- even when the number of rows is unknonwn.
    -- test data:
    DROP TABLE table_1
    CREATE TABLE table_1
      (field_1 VARCHAR2 (1))
    INSERT INTO table_1 (field_1)
    VALUES ('A')
    INSERT INTO table_1 (field_1)
    VALUES ('B')
    INSERT INTO table_1 (field_1)
    VALUES ('C')
    INSERT INTO table_1 (field_1)
    VALUES ('D')
    COMMIT
    SELECT * FROM table_1
    -- Running the code below will create and start
    -- a file named query.sql which will contain the query below,
    -- which will produce the results below that:
    -- query that will be created:
    -- SELECT MAX(DECODE(ROWNUM,1,field_1,NULL))                                      
    -- ||MAX(DECODE(ROWNUM,2,field_1,NULL))                                           
    -- ||MAX(DECODE(ROWNUM,3,field_1,NULL))                                           
    -- ||MAX(DECODE(ROWNUM,4,field_1,NULL))                                           
    -- FROM table_1 GROUP BY NULL;                                                    
    -- results that will be produced:
    -- ABCD
    -- Notice that in this example,
    -- there are only four values concatenated
    -- because there are only four rows in the table. 
    -- If there were more rows, it would concatenate more values. 
    -- The number of concatenated values
    -- is dependent upon the number of rows.
    -- The following dynamic sql uses a single query,
    -- which produces and executes a single query,
    -- whose number of concatenated values is dependent
    -- upon the number of rows in the table.
    -- Because the echo is set off in the first line,
    -- you won't see this code when you run it,
    -- just the query that it creates.
    SET     ECHO OFF FEEDBACK OFF HEADING OFF PAGESIZE 0 VERIFY OFF
    SPOOL   query.sql
    -- This is the start of the single query:
    SELECT  text
    FROM    (SELECT 1                                             AS orderby,
                    'SELECT MAX(DECODE(ROWNUM,1,field_1,NULL))'   AS text
             FROM   DUAL
             UNION
             -- This section is the part that dynamically creates
             -- one additional concatenated value
             -- for each additional row after the first row.
             -- This is just a subquery within the single query.
             SELECT rn                                            AS orderby,
                    '||MAX(DECODE(ROWNUM,'||rn||',field_1,NULL))' AS text
             FROM   (SELECT ROWNUM rn
                     FROM   table_1)
             WHERE  rn > 1
             UNION
             SELECT COUNT (*) + 1                                  AS orderby,
                    'FROM table_1 GROUP BY NULL;'                  AS text
             FROM   table_1)
    ORDER BY orderby;
    -- This is the end of the single query.
    SPOOL    OFF
    START    query
    SET      ECHO ON
    -- If you want to see the file containing
    -- the single query that was created, then just:
    -- SQL> EDIT query.sql

  • SQL query - select one row from each date group

    Hi,
    I have data as follows.
    Visit_Date Visit_type Consultant
    05/09/2009 G name1
    05/09/2009 G name2
    05/09/2009 G name3
    06/09/2009 I name4
    07/09/2009 G name5
    07/09/2009 G name6
    How to select data as follows
    05/09/2009 G name1
    06/09/2009 G name4
    07/09/2009 G name5
    i.e one row from every visit_date
    Thanks,
    MK Nathan
    Edited by: k_murali on Oct 7, 2009 10:44 PM

    Are you after this (one row per date per visit_type)
    with dd as (select to_date('05/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name1' Consultant from dual
                union all
                select to_date('05/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name2' Consultant from dual
                union all
                select to_date('05/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name3' Consultant from dual
                union all
                select to_date('06/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name4' Consultant from dual
                union all
                select to_date('07/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name5' Consultant from dual
                union all
                select to_date('07/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name6' Consultant from dual
                union all
                select to_date('07/09/2009','MM/DD/YYYY') Visit_Date, 'F' Visit_type, 'name7' Consultant from dual)
    select trunc(visit_date) visit_date, visit_type, min(consultant)
    from   dd
    group by trunc(visit_date), visit_type
    order by trunc(visit_date);
    VISIT_DAT V MIN(C
    09/MAY/09 G name1
    09/JUN/09 G name4
    09/JUL/09 G name5
    09/JUL/09 F name7or are you after only one row per date?:
    with dd as (select to_date('05/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name1' Consultant from dual
                union all
                select to_date('05/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name2' Consultant from dual
                union all
                select to_date('05/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name3' Consultant from dual
                union all
                select to_date('06/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name4' Consultant from dual
                union all
                select to_date('07/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name5' Consultant from dual
                union all
                select to_date('07/09/2009','MM/DD/YYYY') Visit_Date, 'G' Visit_type, 'name6' Consultant from dual
                union all
                select to_date('07/09/2009','MM/DD/YYYY') Visit_Date, 'F' Visit_type, 'name7' Consultant from dual)
    select trunc(visit_date) visit_date, min(visit_type) visit_type, min(consultant)
    from   dd
    group by trunc(visit_date)
    order by trunc(visit_date);
    VISIT_DAT V MIN(C
    09/MAY/09 G name1
    09/JUN/09 G name4
    09/JUL/09 F name5

  • Single row from this query without create a group by

    Can I have a single row from this query without create a group by on tipo (TIPO can have only 2 value (A,D)
    SELECT
    CASE TIPO
    WHEN 'D' THEN SUM(IMPORTO) ELSE 0 END DIMPORTO,
    CASE TIPO
    WHEN 'A' THEN SUM(IMPORTO) ELSE 0 END AIMPORTO
    FROM MGIORNALE
    WHERE K_CONTO = '100001' --CONTO
    AND DECODE(T_MOVIM,'MRAP',TO_DATE('31/12/'||to_char(a_competenza),'DD/MM/YYYY'),DATA_RG)
    -- BETWEEN DATAA AND DATAB
    BETWEEN '01/01/2006' AND '31/12/2006'
    --GROUP BY TIPO
    --AND TIPO = COL_conto
    Thanks in advance

    Is like this?
    sum (CASE TIPO
    WHEN 'D' THEN IMPORTO ELSE 0 END) DIMPORTO,

  • Restrict people to see only spool requests from one group of users

    I would like to restrict people to see only spool requests from one group of users defined somewhere inside role.
    I am playing with S_SPO_ACT authorisation object but with no positive result,
    Please help

    There is a note  Note 119147 - Spool: Authorizations (https://service.sap.com/sap/support/notes/119147)
    Object for "Selection authorization for spool requests" is S_ADMI_FC where "Operation authorization" use S_SPO_ACT
    Regards

Maybe you are looking for

  • USB port stopped working in macbook pro

    Hi, i bought a macbook pro, OS X lion, version 10.7.4 a month ago. one of my USB port suddenly stopped working. i am a new mac user, so i have very less idea about mac. i would appreciate if someone could give me step by step solution to this problem

  • AS2 connectivity issue

    Hi, I am facing an issue with connecting through AS2 server to PI server. Below is the scenario: We receive different types of files from customer (EDI and Non EDI). We have maintained one configuration scenario (CS) for EDI and another one for non E

  • Modify ATP Category of an Order

    Hi,   I have to modify the Category(AI) of an Order during the CTM run. I looked into the BADI /SAPAPO/CTM_ORDERS But it seemd not to work.   Appreciate If you please let me know where we can modfiy it. Thanks

  • Can i patch oracle database on  RAC and not patch the RAC software

    Hi there Kindly advise on implications of doing the following 1 i have oracle cluster version 10.2.0.1.0 running 2 nodes 2 i have database version 10.2.0.1.0 i have 4 different databases I want to patch only one database question !! Can i patch the d

  • Howto disable 1394 firewire port in audi

    I have a firewire port in the Audigy 2 audiocard, and also a firewirecard with 3 inputs, supplied with the motherboard. I cannot use the firewirecard of the motherboard for some reason or the other. When I plug in a camera, this device is not recogni