ORACLE Select and group by excluding one field

Dear community,
I have a very simple query (on Oracle 11g) to select 3 fields:
select field1, field2, field3, count(*) from table
where...
group by field1, field2, field3
having count(*) > 10;
Now, what I need, is exclude "field3" from the "group by" since I only need field 1 and 2 to be grouped, but I also need field3 in the output. As far I know, all the fields in the select must be reported also in "group by", so how can I handle that?
Thanks
Lucas

Welcome to the forum!
Whenever you post please provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION). And when you post code use code tags, \ on the line before and after the code to preserve formatting. See the FAQ for other syntax and highlighting options.
{quote}
As far I know, all the fields in the select must be reported also in "group by", so how can I handle that?
{quote}
Correct - for an aggregate query all columns in the select must be either aggragate functions or in the GROUP BY.
{quote}
Now, what I need, is exclude "field3" from the "group by" since I only need field 1 and 2 to be grouped, but I also need field3 in the output
{quote}
Well what is it you are counting? And how should the values of field3 relate to those groups?
Post some sample source data and the sample result data you want to produce.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How to select and copy more than one field in SMARTFORMS

    Hello, I have about 60 fields in my smartforms, I need to copy them and paste once more at the same page. There is a problem, I can not select and copy more than one field. Is there some trick to copy and paste more than one element simultanicly?

    Hi,
    There is no way to copy multiple elements in smartform.
    you have to do one by one only

  • Partition Name in Select and Group-By

    Is there a function that returns the partition name a row is stored in? I'd like to use it in a SELECT statement, if it exists.
    The goal is to get row counts per partition to determine skew on a hash-based partition (otherwise, I'd just select and group-by the partition key). I want to do something like this:
    SELECT PARTITION_NAME, COUNT(*) as PER_PART_COUNT
      FROM SOMETABLE
    GROUP BY PARTITION_NAME;Obviously, I would replace the string "*PARTITION_NAME*" with whatever function returns that value.
    NOTE: Before the forum sharks jump all over me, I did search the documentation and forums, but I came up empty handed.

    Hi,
    This is hokey - but you can use the undocumented function "tbl$or$idx$part$num" like so:
    SELECT   atp.partition_name
           , COUNT (*) AS count_rows
        FROM all_tab_partitions atp
           , (SELECT tbl$or$idx$part$num ("SCOTT"."TAB1"
                                        , 0
                                        , 1
                                        , 0
                                        , partition_col1 -- your 1st partition key column
                                        , partition_col2 -- your 2nd partition key column
                                         ) AS part_num
                   , 'TAB1' AS table_name
                   , 'SCOTT' AS owner
                FROM scott.tab1) pt
       WHERE atp.table_name = pt.table_name
         AND atp.table_owner = pt.owner
         AND atp.partition_position = pt.part_num
    GROUP BY atp.partition_name;Note - this probably won't perform well at all... but it could be an option...
    Message was edited by:
    PDaddy
    ... On 2nd thought - don't do it - it seems it is pretty unstable - brought my session to a halt a couple of times... Forget I mentioned it :)
    ... On 3rd thought - if you add ROWNUM - it works fine - seems you need to materialize the result set in the inner query - like so:
    CREATE TABLE part_tab (part_key int
                         , a int
    partition by range (part_key)
    (partition p1 values less than (100)
    ,partition p2 values less than (200)
    ,partition p3 values less than (maxvalue)
    insert into part_tab
    select rownum
         , rownum
    FROM all_objects
    where rownum <= 1000; SELECT atp.partition_name
         , COUNT(*) AS count_rows
    FROM all_tab_partitions atp
       , (SELECT TBL$OR$IDX$PART$NUM("PART_TAB", 0, 1, 0, part_key) AS part_num
               , 'PART_TAB' AS table_name
               , user AS owner
               , ROWNUM AS rn -- Materialize the result set by adding ROWNUM...
          FROM part_tab) pt
    WHERE atp.table_name = pt.table_name
      AND atp.table_owner = pt.owner
      AND atp.partition_position = pt.part_num
    GROUP BY atp.partition_name;

  • How do you select and move more than one bookmark at a time? Shift+Click does not select multiple items that are next to one another in a list because the item

    How do you select and move more than one bookmark at a time?
    Shift+Click does not select multiple items that are next to one another in a list because the items open in firefox before this happens.

    Use the bookmarks library. You may use Shift +Click, and Ctrl + Click to create groupings of selected bookmarks to drag and drop.
    * one method of opening the bookmarks library is keyboard shortcut <br /> Ctrl+Shift+B (Windows)
    *see also [[How to use bookmarks to save and organize your favorite websites]]
    *and [[Use bookmark folders to organize your bookmarks]]

  • Select and Drag More Than One Photo

    I can no longer select and drag more than one photo at a time. With one photo it works fine. If I select more than one, I can't move them, so I have to add pictures to albums one at a time, which is rather tedious.
    This has only started happening recently. Possibly after updating to 10.6.8????
    Anu ideas please?
    iPhoto09, v8.1.2

    Then I would try a reinstall:
    To re-install iPhoto
    1. Put the iPhoto.app in the trash (Drag it from your Applications Folder to the trash)
    2a: On 10.5:  Go to HD/Library/Receipts and remove any pkg file there with iPhoto in the name.
    2b: On 10.6: Those receipts may be found as follows:  In the Finder use the Go menu and select Go To Folder. In the resulting window type
    /var/db/receipts/
    2c: on 10.7 they're at
    /private/var/db/receipts
    A Finder Window will open at that location and you can remove the iPhoto pkg files.
    3. Re-install.
    If you purchased an iLife Disk, then iPhoto is on it.
    If iPhoto was installed on your Mac when you go it then it’s on the System Restore disks that came with your Mac. Insert the first one and opt to ‘Install Bundled Applications Only.
    If you purchased it on the App Store or have a Recent Mac you can find it in your Purchases List.

  • Is there any way to include excluding one field

    hi all,
    is there any way to include a structure or type in another structure or type by excluding one field?
    regards
    hyma

    I think you are trying to include 2 structures but it is giving error that some fields are common
    you can overcome that like this , these are the 2 additions
    INCLUDE STRUCTURE ZTAB AS name1.
    INCLUDE STRUCTURE ZTAB AS name1 RENAMING WITH SUFFIX name2
    for more info check the help for INCLUDE STRUCTURE

  • Exclude one field from Logical Database's dynamic selection screen

    Hi Guru,
    I have a requirement to amend a program to exclude the document number field (bsik-belnr) from the dynamic selection-screen of the logical database KDF(Vendor Database) so that the program will not filter according to the document number.
    I have use the below syntax in my zprogram.
      selection-screen exclude select-options: doc-no.
    However I get syntax error "The addition EXCLUDE is only allowed in INCLUDE DBKDFSEL".
    Please advice.
    Best Regards,
    Fung

    The selection part of the logical database defines input fields for selecting data.
              The runtime environment displays these on the selection screen when you run an executable program linked to the logical database.
              Include called DB<ldbname>SEL.
            SELECTION-SCREEN BEGIN OF VERSION ver TEXT-xxx.
                                                                    SELECTION-SCREEN EXCLUDE ... .
                                                    SELECTION-SCREEN END OF VERSION ver.
    Defines a selection screen version (with a three-character name ver ). Between BEGIN OF VERSION and END OF VERSION , you can exclude selection screen objects for the version ver , i.e. remove them from the selection screen with SELECTION-SCREEN EXCLUDE.
              SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE dbtab
    If one of these tables is active in the report (i.e. it is declared under TABLES or lies somewhere on the path from the root of the database hierarchy to a table declared with TABLES ), a pushbutton called 'Dynamic selections' appears on the selection screen.

  • Problem in creating group above AND group left in one report!

    Hi all,
    I need a report that is a combination of group above and group
    left.
    Suppose I have 3 table (Emp, Sales, Product):
    Emp Table has 2 column
    - Emp_PK
    - Emp_Name
    Sales Table has 4 column
    -Sales_PK
    -Sales_Date
    -Emp_FK
    -Produck_FK
    -Quantity
    Product Table has 3 column
    -Product_PK
    -Product_Name
    -Product_Price
    I want to make Employee Sales Report For The Month that will
    look like this:
    Emp Number___: Emp_PK
    Emp Name_____: Emp_Name
    Sales Date______Product_Name____Quantity \(2 sales
    ________________Product_Name____Quantity /the date)
    Sales_Date______Product_Name____Quantity
    As you can see this consist of group above (The Employee) and
    group left (The Sales and Product).
    I create this by using 2 queries and link them (the Emp_PK from
    1st query and Emp_FK from 2nd query) on the report builder using
    data link.
    The first query is:
    Select Emp_PK, Emp_Name from Emp
    The second query is
    Select Emp_FK, Sales_Date, Product_Name, Quantity
    From Sales, Product
    Where Product_PK=PRODUCT_FK
    I then create the layout for second query and choose group left
    for Sales_Date using wizard and I create additional layout to
    for the employee.
    The problem is that when I run this report, it will print ALL
    the employee record first (including employee who has NOT sale
    anything) and then on the last page it will print the record of
    Last employee on the Emp table and ALL sales record (including
    those that is done by other employee).
    This report will run correctly if I choose an exact employee
    (For example by adding Where Emp_PK=1111 in the first query) to
    report all of the sales done by this person (employee with emp
    number of 1111). However I need the report to run and print
    ONLY those employee who has Sales Records!
    I thought that by linking the 2 queries in Data Model, it will
    have the same effect as linking using the WHERE clause in query.
    If suppose I create a query like this:
    SELECT Emp_PK, Emp_Name, Sales_Date, Product_Name, Quantity
    FROM Emp, Sales, Product
    WHERE Emp_PK=Emp_FK AND Product_PK=Product_FK
    The report will run OK but I can only choose EITHER group above
    or group left for this ONE query methods in report Wizard.
    Sorry if it is a long question but I hope you can see what I am
    trying to do.
    Thanks in advance for any tip.

    hello,
    of course you can create group left and group above blocks in a
    single report.
    you might want to use the INSERT REPORT BLOCK instead of the
    report wizard, as the report wizard only allows you to use one
    report layout per report, where the report block wizard (invoked
    by INSERT REPORT BLOCK) allows you to choose on a per-block
    basis.
    of course you can create the blocks completely from scarth by
    hand, if you want to.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Comparison of two structures excluding one field

    Hi,
    I need to make comparisons of two complete data structures, excluding from the comparison one field that should not be compared or considered to obtain a result of equality of both structures.
    Somebody know a sentence or practical way to make this comparison (with one field less)?
    Example:
    DATA: im_data_new TYPE mereq_item,
                im_data_old TYPE mereq_item.
    Both structures has 146 fields, and I need to exclude from the comparison the 64th field.
    Thanks in advance and greetings,
    Mayra.

    clear that field value in old and new before comparing the structures.
    Thomas

  • Exclude one field from application.cfm loop

    i am using a cfloop collection tag in the application cfm file to loop through and remove special charachters from submitted forms for xss protection. I want to exclude one or two fields from this because they are date time fields so can't have all the restrictions all of the other fields can. I am picturing something like
    <cfloop collection="blah" item="blahblah">
         <cfif field name is not one of the date time fields>
    < general remove bad charachters code>
         <cfelseif field name is one of date time fields>
    <remove special charachters code>
    </cfif>
    </cfloop
    how do i get the field name to use in the condition above?

    Ummm...
    <cfloop collection="form" item="field">
    <cfif field NEQ "aDateField" AND field NEQ "bDateField" AND field NEQ "cDateField">
       Processs the non-date fields
    <cfelse>
      Process the date fields
    </cfif>
    </cfloop>
    Or slightly easier to maintain.
    <cfloop collection="form" item="field">
    <cfif NOT ListFind(field, "aDateField,bDateField,cDateField")>
       Processs the non-date fields
    <cfelse>
      Process the date fields
    </cfif>
    </cfloop>
    Or the best yet, would be to provide the list you are checking against from sometype of data repository where it is easy to maintain, like a database or configuration or something.  But I will leave that exercise to you to figure out.

  • Grouping more than one fields?

    Apologies if this has been asked before, but I could not find it in the forum.
    I have 2 fields that contain numbers, and what I would like to do is that if one or both fields starts with a certain number, I want them grouped together.  Sometimes, only 1 of this fields are populated.  If both are populated, and go with the first field only.
    I would then would like to make a graph based on this groupings.
    Any help is greatly appreciated.
    Thank you.

    Something like this should work for you...
    IF LEFT({TableName.FieldNameA}, 1) = 3 OR LEFT({TableName.FieldNameB}, 1) = 3 THEN True ELSE False
    HTH,
    Jason

  • Oracle SELECT and storage technique

    Hi,
    I have 2 questions please. First of all, what kind of storage mechanism is used in Oracle e.g Oracle 11g, is it HEAP BASED or some other?
    Actually I am not able to search how Oracle stores the data into tables as I've heard that heap based storage is a mechanism in which the data is saved in the same order as it is being inserted?
    What is the Linear Search?
    I've performed test on more than 40 tables with simple SELECT and Elapsed time is always favoring 16k block size when compared to 4k and 8k data block size.
    Just thinking the reason that why SELECT is favoring 16k in all the tests, because the data is saved in hundreds and thousands of data blocks and if it is in the smaller data block, it has to go and search more and more data blocks, is it true?
    Please help me with your expert opinions and if possible please suggest me some book or paper which explains the ORACLE STORAGE MECHANISM AND SEARCHING MECHANISM i.e. LINEAR search or what?
    I'll appreciate the suggestions.
    Thanks a lot.
    Best Regards,
    John

    John-M wrote:
    I see you've also re-opened an older question which overlaps with this topic - so I'll be making some comments there as well: Re: single col v/s multi col table elapsed time comparison
    I have 2 questions please. First of all, what kind of storage mechanism is used in Oracle e.g Oracle 11g, is it HEAP BASED or some other?
    The most commonly used mechanism is heap-based - rows are put wherever the next convenient space happens to be.
    Actually I am not able to search how Oracle stores the data into tables as I've heard that heap based storage is a mechanism in which the data is saved in the same order as it is being inserted?
    Not quite - but see other post.
    What is the Linear Search? Depends how technical you want to be - the implication is that you "start at the beginning, work through to the end and then stop". The search it linear because the time it takes to complete it proportional with the volume of data available.
    >
    Please help me with your expert opinions and if possible please suggest me some book or paper which explains the ORACLE STORAGE MECHANISM AND SEARCHING MECHANISM i.e. LINEAR search or what?
    The Concepts manual is pretty good on storage.
    Regards
    Jonathan Lewis

  • Select and ... only one time in table - how?

    Hallo,
    in SRList from SRDemo "Select and View / Edit" comes only on top of the table.
    In my page it comes on top and bottom of the table. why is it so and how i can customize it?
    i don't see the point.

    There isn't much point when you only have 10 items in the table, but imagine the case where there are 100 or more rows in the table (possibly after the user has selected to view all rows). Then it would be conveniant to have the selection facet at the bottom of the table too, so that the user doesn't need to scroll all the way back up to the top.
    As for customisation, I don't think that you can change the behaviour in that way.

  • Multi data providers (oracle DB and Excel file) in one BO report

    I have to create one BO report. There is one Excel file, with Type, type_ID,(each type has many different type_ids), eg
    type                 type_id
    IHEI                  IHEI121
    IHEI                  IHEI132
    IHEI                  IHEI212
    IHDI                 IHDI511
    IHDI                 IHDI232
    IDWU              IDWU212
    IDWU              ...............
    now I want to count the occurrences of these type_ids in the oracle database.
    This should be relatively easy, with
    select type, type_id, count(type_id)
    from my_table
    where type in ('IHEI', ...)
    however, since the there are many more data in the database than in the Excel file, it will also count those type_ids that are not in the Excel file
    So, how to get rid of those type_ids and keep only those coming from the Excel file?
    thanks for your help!

    Hi Eric,
       In the main report, bring in your table.field(s) etc.
    Then create a sub report and hook it up to the Excel file.
    Link the sub to the main and display (...by "Type" ? ...)
    all the Type_ID's.
    Happy Hunting,
    The Panda

  • Creation of view with clob column in select and group by clause.

    Hi,
    We are trying to migrate a view from sql server2005 to oracle 10g. It has clob column which is used in group by clause. How can the same be achived in oracle 10g.
    Below is the sql statament used in creating view aling with its datatypes.
    CREATE OR REPLACE FORCE VIEW "TEST" ("CONTENT_ID", "TITLE", "KEYWORDS", "CONTENT", "ISPOPUP", "CREATED", "SEARCHSTARTDATE", "SEARCHENDDATE", "HITS", "TYPE", "CREATEDBY", "UPDATED", "ISDISPLAYED", "UPDATEDBY", "AVERAGERATING", "VOTES") AS
      SELECT content_ec.content_id,
              content_ec.title,
              content_ec.keywords,
              content_ec.content content ,
              content_ec.ispopup,
              content_ec.created,
              content_ec.searchstartdate,
              content_ec.searchenddate,
            COUNT(contenttracker_ec.contenttracker_id) hits,
              contenttypes_ec.type,
              users_ec_1.username createdby,
              Backup_Latest.created updated,
              Backup_Latest.isdisplayed,
              users_ec_1.username updatedby,
              guideratings.averagerating,
              guideratings.votes
         FROM users_ec users_ec_1
                JOIN Backup_Latest
                 ON users_ec_1.USER_ID = Backup_Latest.USER_ID
                RIGHT JOIN content_ec
                JOIN contenttypes_ec
                 ON content_ec.contenttype_id = contenttypes_ec.contenttype_id
                 ON Backup_Latest.content_id = content_ec.content_id
                LEFT JOIN guideratings
                 ON content_ec.content_id = guideratings.content_id
                LEFT JOIN contenttracker_ec
                 ON content_ec.content_id = contenttracker_ec.content_id
                LEFT JOIN users_ec users_ec_2
                 ON content_ec.user_id = users_ec_2.USER_ID
         GROUP BY content_ec.content_id,
         content_ec.title,
         content_ec.keywords,
         to_char(content_ec.content) ,
         content_ec.ispopup,
         content_ec.created,
         content_ec.searchstartdate,
         content_ec.searchenddate,
         contenttypes_ec.type,
         users_ec_1.username,
         Backup_Latest.created,
         Backup_Latest.isdisplayed,
         users_ec_1.username,
         guideratings.averagerating,
         guideratings.votes;
    Column Name      Data TYpe
    CONTENT_ID     NUMBER(10,0)
    TITLE          VARCHAR2(50)
    KEYWORDS     VARCHAR2(100)
    CONTENT          CLOB
    ISPOPUP          NUMBER(1,0)
    CREATED          TIMESTAMP(6)
    SEARCHSTARTDATE     TIMESTAMP(6)
    SEARCHENDDATE     TIMESTAMP(6)
    HITS          NUMBER
    TYPE          VARCHAR2(50)
    CREATEDBY     VARCHAR2(20)
    UPDATED          TIMESTAMP(6)
    ISDISPLAYED     NUMBER(1,0)
    UPDATEDBY     VARCHAR2(20)
    AVERAGERATING     NUMBER
    VOTES          NUMBERAny help realyy appreciated.
    Thanks in advance
    Edited by: user512743 on Dec 10, 2008 10:46 PM

    Hello,
    Specifically, this should be asked in the
    ASP.Net MVC forum on forums.asp.net.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

Maybe you are looking for

  • What files do i need to download?

    I'm trying to figure out what files I need to download. I eventually want to install everything I possibly can that's available from Oracle, but I'm trying to tacle just the Database + Forms + Reports right now since that's what my college professor

  • Build an ID CS4 project in snow leopard/lion

    Hi All, I got a new machine with leopard(10.6.7)  and xcode 3.2.5 installed when I tried to build a sample sdk project then it starts give me error of missing base sdk 10.4u I could change my SDK to 10.6 and GCC compiler to GCC 4.0 then it gives me e

  • Over 400.000 Spoolfiles in three days

    Hello together, we have several V6R1 partiotions. Since a few days I have on two partitions a lot of Spoolfiles with the following content: Switch to user QSECOFR failed This is the only text in the spoolfile. File        User        User Data   Sts 

  • Technical Content Transport

    While trying to transport Technical Content from Dev to QA, the import log showed error 'DataSource 0BWTC_C02 does not exist in source system LSQCT100 of version A'. As a matter of fact, all datasources we tried to import resulted in similar error me

  • I try to open itunes it says that it has encountered a problem

    every time i try to open itunes it says that itunes has encountered a problem and needs to close i did this with my original cd and it says quicktime wasnt installed so- i updated itunes and it still has the same problem what do i do?