Query Group by problem

Hi,
Oracle - 10.2.0
I am writing a query for a report generation. And my requirement is, i need to group a column in a query which selects many columns
eg:
SELECT no_id,v_no,v_name,v_addr FROM tb_name_a
GROUP BY v_no
any options plz advice...
TIA,

Hi ORCLDB, I guess your requirement can be full filled by following query
SELECT no_id,v_no,v_name,v_addr FROM tb_name_a
ORDER BY v_no
i.e. : use ORDER BY instead of GROUP BY clause
Message was edited by:
imrahul

Similar Messages

  • Reg: Query group by problem

    Hi,
    I am trying to write query for report generation.According to my client requirment I need to calculate the difference
    between two date columns for "n" number of rows and i need to find the number of rows which are smaller
    than 2 and number of rows which are greater than 2 and calculate the percentage for number of rows which are smaller than 2.
    It must grouped by a third column
    I tried like this, but it shows that date column is not a grouped .....
    But I dont want to group that date column... Plz adivce....
    SELECT table1.column2,
          table2.column3,
          COUNT(*),
         CASE
                 WHEN TO_NUMBER (table1.DTT_column3 - table1.DTT_column4) <=2
                 THEN COUNT(*)
                 ELSE NULL
            END
             AS sucess_count,
         CASE
                 WHEN TO_NUMBER (table1.DTT_column3 - table1.DTT_column4) >2
                 THEN COUNT(*)
                 ELSE NULL
            END
            AS fail_count,
         FROM
         table1,
         table2
         WHERE table1.column1 =       table2.column2
         AND table1.column4 = value1
         GROUP BY table1.column2,table2.column3;TIA,
    Message was edited by: ORCL
    ORCLDB

    May be something like this.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
    PL/SQL Release 10.2.0.2.0 - Production
    CORE    10.2.0.2.0      Production
    TNS for HPUX: Version 10.2.0.2.0 - Production
    NLSRTL Version 10.2.0.2.0 - Production
      1  with t
      2  as
      3  (select 1 id, to_date('01.02.2008','dd.mm.yyyy') date_1,
      4                to_date('03.02.2008','dd.mm.yyyy') date_2 from dual union all
      5   select 1,    to_date('03.02.2008','dd.mm.yyyy'),
      6                to_date('04.02.2008','dd.mm.yyyy') from dual union all
      7   select 2,    to_date('05.02.2008','dd.mm.yyyy'),
      8                to_date('06.02.2008','dd.mm.yyyy') from dual union all
      9   select 2,    to_date('01.02.2008','dd.mm.yyyy'),
    10                to_date('05.02.2008','dd.mm.yyyy') from dual
    11  )
    12  select count(case when to_number(date_2 - date_1) <= 2 then 1 end) diff_2,
    13        count(case when to_number(date_2 - date_1) > 2 then 1 end) diff_Greater_2,
    14    1 - (  count(case when to_number(date_2 - date_1) > 2 then 1 end)
    15         / count(case when to_number(date_2 - date_1) <= 2 then 1 end)
    16        ) percent
    17  from t
    18  group by rollup(id)
    19* having grouping_id(id) = 1
    SQL> /
        DIFF_2 DIFF_GREATER_2    PERCENT
             3              1 .666666667It will be always useful if you could post your full oracle version and a sample test data.
    Regards
    Raj

  • Linking Query group to an SAP role

    I am able to link the Query group to the role but when we test the user does not have access to it. I know this used to be a problems years ago that I thought was fixes. Any ideas on how to get this to work?

    Hi,
    Assign the required user groups to the user in Sq03. if user still getting same error even after assignments in Sq03, ask user to please change query areas as below and check.
    Sq01 --> Environment --> Query areas --> select "Stanard area (client-specific).
    Regards,
    Gowrinadh

  • Query in item problem

    Hellou everybody.
    I need your help. I am using forms 6i and i have a block with some non DB items. But items are synchronize with DB items for viewing results. I use this items for diplaying results from DB tables. In enter query mode i write condition in this text items and execute query.
    My problem is that i have text item which is VARCHAR2 type and I need to enter the condition for example > 1000. But i don't know how to convert this field to number. When i execute query under char type it not work properly (other result). I tried to change data type to number but i can't because it's not alowed to mixed types.
    select * from table_name where pag_cis > 100 - i need this
    select * from table_name where pag_cis > '100' - i have this
    Can you help me???

    You may use the set_block_property procedure built-in and the 'default_where' property so as to execute the query using the contents of your item (with the name of column , of course).
    Afterwards , you navigate to the db items block (with go_block('blockname')) and execute the query (built-in 'execute_query').
    Hope it helps
    Sim

  • Multi-query group above report creates more pages

    Hi,
    I have a multi-query group above report (paper only), the parent group creates 5 rows(subframes) all onto the same page, but then creates 4 more IDENTICAL pages!!?
    at the end I have 5 repating frames and 5 pages.
    If I set Maximum Records per Page to 1, I have 5 pages (IDENTICAL) with the first frame only...
    any idea?
    cheers
    Matteo

    hello,
    you will have to create a counter, that tells you the numbers of students (summary-column, function : count, reset on : course) and create a format-trigger on the heading that hides it when the number of students is 0.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Query Group in Query Category different with Authorization's group number

    Hi All,
    In Authorization screen, it allowed to authorize up to 20 query group
    Whereas in Query Category window, it has only max 15 query group.
    Anyone has idea on why is the difference?
    Thanks in advance,
    MH

    You have a very good point.  I believe something must be for system to use during development.  You may post a development request to see if the next version could have matched numbers of query groups.  The forum is on this link:
    /community [original link is broken]
    Thanks,
    Gordon
    Edited by: Paulo Calado on Jun 19, 2009 3:33 PM

  • Query Group and Authorization group is different

    Hi,
    In Authorization screen, it allowed to authorize up to 20 query group. Whereas in Query Category window, it has only max 15 query group. For future patch, is it possible to have matched query groups?
    Thanks.
    Regards,
    MH

    Hi,
    In Authorization screen, it allowed to authorize up to 20 query group. Whereas in Query Category window, it has only max 15 query group. For future patch, is it possible to have matched query groups?
    Thanks.
    Regards,
    MH

  • Configure custom query group in navigation menu

    How do we configure custom query groups? Say for example: I have created a custom query group and added my custom query definitions to it. How do I configure this so that when I click on Contract Management Tab on the workbench, my custom query group is invoked?
    I need to configure custom query group in navigation menu. Any help would be appreciated.
    Regards,
    Bindu Sharma

    Hi Bindu,
    As per my understanding, it is standard and query group cannot be added in the navigation but you can add your quries under Agreement and Claus Library.
    Kindly refer the blog for the same: http://scn.sap.com/docs/DOC-55733
    Let me know if you need any other information.
    Thanks,
    Kushagra A

  • Saved query groups authorization

    Dear All,
    Saved query groups - no.1 to no. 20 are available in the authorizations form.
    I see there are only 15 groups  in the query manager --> manage categories, and in the authorizations are 20. the remnants are 5. Where will the five groups to be used and be able to find ?
    I use SBO 2004A. I also see that it is happened in SBO 2005A. I have tried to find in SAP notes but I can't see.
    I appreciate your answers. TIA
    Rgds,

    Hi Steve,
    Seems that noone here on SDN knows the answer (including myself)
    I suggest that you raise that to SAP Support - to have them checking the case.
    Sorry,
    Frank

  • Easiest way to know the query group name?

    Hello All,
    This has been nagging at me for quite some time now. Would appreciate you inputs on the ways to find out the query group name for a set of queries we see on the UI.
    The obvious method is to search your query group from the list of query groups that system shows when we navigate to Setup->Queries and Reports->Query Groups. Do we have some other ways as well.
    Thanks In Advance
    Devesh

    Hi Devesh,
    If you know the query definition then the easiest way to find the query group would be to use "Search Query Groups by Queries Used" query on the Query Groups list page. This query allows you to select a query definition and returns the query group using the query.
    Or you could use "Query Group Review" query on the Query Groups list page. This returns all queries within all Query Groups. You can further refine your search by Query Name or Internal Name of the query you are interested in.
    If you want to do a general search for all buy-side list page or buy-side picker page query groups, search for <buylist> and <buypick> respectively.
    Hope this helps.
    Regards,
    Vikram

  • Group by problem at pivot table

    Hi,
    firstly i am making a table, everything is ok,
    after i click pivot table, st_desc column writes same value again, i couldnt understand the reason.
    please check my screen shots below,
    http://www.odilibrary.com/index.php/oracle-data-integrator/99-group-by-problem
    kindly advise please

    that my fault
    there is a null at the beginning of the value, they are different,
    sorry

  • GROUP BY PROBLEM IN QUERY

    HI ALL,
    MY TABLES ARE
    1. PRTRINCE FIEDS ARE: SHOP,TIMESAVED,TIMETAKEN,EMPNO
    2. PRMAINCM : UNIT, STDHOURS
    NOW I WANT TO DO THE FOLLOWING THING
    I WANT TO CALCULATE THE % FOR EACH SHOP AND SHOW ACCORDING TO SHOP
    I MEAN
    SELECT A.SHOP,SUM(A.TIMETAKEN),SUM(A.TIMESAVED)
    , SUM(A.TIMESAVED)*100/COUNT(A.EMPNO)*B.STDHOURS FROM
    PRTRINCE A, PRMAINCM B WHERE
    A.SHOP=B.UNIT
    GROUP BY A.SHOP
    BUT IT DOES NOT WORK AS IT SAYS COUNT(A.EMPNO)*B.STDHOURS NOT A GROUP BY EXPRESSION
    SUGGEST SOME QUERY THAT CAN SOLVE MY PROBLEM
    REGARDS
    ABHI.

    Hi Abhi,
    Include B.STDHOURS in your group by clause and check.
    SELECT A.SHOP,
           SUM(A.TIMETAKEN),
           SUM(A.TIMESAVED),
           SUM(A.TIMESAVED)*100/COUNT(A.EMPNO) * B.STDHOURS
    FROM PRTRINCE A, PRMAINCM B
    WHERE A.SHOP=B.UNIT
    GROUP BY A.SHOP, B.STDHOURS
    Tip: use proper brackets in your script as per your requirement:
    select 5 * 100 / 10 * 4 from dual
    =>200
    select 5 * 100 / (10 * 4) from dual
    =>12.5Slight modifications in the script: included disctinct for count(empno)
    with PRTRINCE as (
    select 'A' as SHOP, 10 as TIMESAVED, 50 as TIMETAKEN, 1 as EMPNO from dual union all
    select 'A' as SHOP, 15 as TIMESAVED, 45 as TIMETAKEN, 2 as EMPNO from dual union all
    select 'A' as SHOP, 5 as TIMESAVED, 60 as TIMETAKEN, 2 as EMPNO from dual union all
    select 'A' as SHOP, 15 as TIMESAVED, 45 as TIMETAKEN, 2 as EMPNO from dual union all
    select 'B' as SHOP, 12 as TIMESAVED, 48 as TIMETAKEN, 3 as EMPNO from dual
    PRMAINCM as
    select 'A' as UNIT, '8' as STDHOURS from dual union
    select 'B' as UNIT, '10' as STDHOURS from dual
    SELECT A.SHOP,
           SUM(A.TIMETAKEN) TIMETAKEN,
           SUM(A.TIMESAVED) TIMESAVED,
           (SUM(A.TIMESAVED)*100/COUNT(distinct A.EMPNO) * B.STDHOURS) XYZ
    FROM PRTRINCE A, PRMAINCM B
    WHERE A.SHOP=B.UNIT
    GROUP BY A.SHOP, B.STDHOURS
    SHOP     TIMETAKEN     TIMESAVED     XYZ
    A     200     45     18000
    B     48     12     12000Regards
    Imran
    Edited by: Imran Soudagar on Apr 13, 2010 10:35 AM; modified script with sample data

  • CostCenter Group Aggregation problem. High Priority Issue.

    Hi Experts,
    I have very crital issue in the report, Help needed.
       I had some kind of requirement in one of the Overhead cost report, need to combine the COPA data and Costcenter(Over Head cost) data.  I have a problem with Costcenter Group aggregation on the report.
    I have Restricted 2-Keyfigures  want to derive the 3rd Keyfigure values. I given the below exmaple of the data. In my report I just want to display the KeyFigure(KF-A,B,C). I dont want to Display the Cost Center group/Costcenter Number in my report. My report ouput will be one line. But If I removed the costcenter Group I am seeing different values of the Keyfigure C, If I display the Costcenter comng with differnt Values. I am expecting the values in the column C is 1400 but it is coming like 3600.
    Please guide me how to design the Keyfigures if I want to get the value 1400 in theKeyFigre C with out Showing the Costcenter In the report.
    Cost-Center Group  R00048                         
                      Costcenter     KF-A     KF-B           KF-C
         10113     10     10          100
         10114     20     20          400
         10115     30     30          900
              60     60          1400(Insted of this its comming like 3600)
    Appreciate the response.
    Thanks,
    Venkata

    Hi,
    Check the display properties of key figure in Query Designer/Info object level.
    Set the property accordingly.
    I hope it will help.
    Thanks,
    S

  • Oracle Query Rewrite Alias Problem

    Hi,
    The problem desribed below is regarding the use of oracle aggregate awareness through the use of query rewrite.
    2 materialized views exist (one agg per day, one agg per month) and 1 dimension exists for time (date - month - quarter - year)
    Query rewrite seems to be working fine for a query as such (alias sql = alias mv):
    select DDFPC.MONTH_NO
    from BIDATA_MAIN.DF_REPOSITORY_SUBSET DF2, BIDATA_MAIN.DD_TIME DDFPC
    where DF2.FINANCIAL_PROCCESSING_DATE_ID = DDFPC.DATE_ID and DF2.ROUTING_CODE_ISS IN ('FPC','NCC')
    group by DDFPC.MONTH_NO
    However, considering our reporting tool generates aliases on the fly, we could get the following query (alias sql <> alias mv):
    select T2.MONTH_NO
    from BIDATA_MAIN.DF_REPOSITORY_SUBSET DF2, BIDATA_MAIN.DD_TIME T2
    where DF2.FINANCIAL_PROCCESSING_DATE_ID = T2.DATE_ID and DF2.ROUTING_CODE_ISS IN ('FPC','NCC')
    group by T2.MONTH_NO
    --> for the second query, query rewrite refuses to correctly use the dimension – it’ll rewrite to the DD (daily) aggregate, but not to the MM (monthly) aggregate
    Investigation gives: QSM-01072: materialized view, DA_REPOSITORY_MERCHANT_MM, and query have different joins between tables, DF_REPOSITORY_SUBSET and DD_TIME
    So*: How can query rewrite be forced to take place with different aliases between query & materialized view – taken into account a dimension is used for aggregation-awareness?
    This seems to indicate it should work...

    You are missing a join on the file_id column
    i.e.
    select sum(f.BLOCKS), sum(d.BLOCKS) from dba_free_space f ,dba_data_files d where f.TABLESPACE_NAME=d.TABLESPACE_NAME and f.TABLESPACE_NAME like SUBSTR('KU_TSD_1',0,10)
    and f.file_id = d.file_id
    This might have been easier to detect if you had removed the sum aggregation and looked at the data coming back from the raw query.

  • Year Ago Measure group by problem.

    Hi,
    In my report I have two measures Revenue and Revenue Year Ago.
    Revenue Year ago is calculated based on the Ago functionalty and the time dimension level is "Year"
    AGO(Fact.Revenue, TimeDimnesion."Year", 1).
    The problem is that the column measure Revenue Year Ago is not getting added up to display data when we select based on the time dimension.
    e.g.
    Dimnesion Month-Code Revenue Revenue Year Ago
    A Jan-10 100 90
    A Feb-10 200 160
    B Feb-10 250 200
    In my report I want to display the Dimension, Revenue and Revenue Year Ago for the month of 'Jan-10' and 'Feb-10'
    so that automatic group by happens for the measures like this.
    Dimnesion Revenue Revenue Year Ago
    A 300 250
    B 250 200
    But this is not happening when I apply the filter for Month-Code in ('Jan-10' and 'Feb-10') and the result what OBIEE gives is null value for Revenue Year Ago.
    Dimnesion Revenue Revenue Year Ago
    A 300 NULL
    B 250 200
    But when I remove the Month-Code filter it gives the correct result.
    So is there something that I am missing out. Please advice.
    TimeDimnesion Hierarchy is Total(Grand Total) -> Year (Year Id, Year Code) -> Qtr (Qtr Id, Qtr code) -> Month
    (Month-Id,Month-Code) -> Detail (Day-Id, Day-Code)
    Regards,
    Bhavik

    if you can give a small test case to play around, it
    might be helpfule.
    put the data in the table and show the output you
    desire.An example-
    STORE
    StoreID StoreName Location
    s1 ABC NY
    s2 XYZ LA
    PRODUCT
    ProdID ProdName
    p1 foo
    p2 moo
    TRANSACTION
    TransID Fiscal_Yr StoreID ProdID Rating Price
    t1 2002 s1 p1 A 10
    t2 2002 s1 p1 A 80
    t3 2002 s1 p2 A 15
    t4 2002 s1 p1 B 20
    t5 2003 s2 p1 B 50
    If the query below is executed-
    SELECT t.Fiscal_Yr, s.StoreName, p.ProdName, t.Rating, SUM(t.Price) Revenue
    FROM STORE s, PRODUCT p, TRANSACTION t
    WHERE s.StoreID = t.StoreID
    AND p.ProdID = t.ProdID
    GROUP BY t.Fiscal_Yr, s.StoreName, p.ProdName, t.Rating
    ORDER BY t.Fiscal_Yr, Revenue DESC
    then, we get
    Fiscal_Yr StoreName ProdName Rating Revenue
    2002 s1 foo A 90
    2002 s1 foo B 20
    2002 s1 moo A 15
    2003 s2 foo B 50
    But, irrespective of different ratings for the same product, the revenue should be added and I should get rating as listed in the first transaction for that product for a particular store and Fiscal_Yr. So, my desired result should be-
    Fiscal_Yr StoreName ProdName Rating Revenue
    2002 s1 foo A 110
    2002 s1 moo A 15
    2003 s2 foo B 50

Maybe you are looking for

  • Req import fails with POCIRM-24a: ORA-01400:

    Req import fails with. POCIRM-24a: ORA-01400: cannot insert NULL into ("PO"."PO_REQ_DISTRIBUTIONS_ALL"."D

  • I'm having to clear cache constantly now in order to load pages.

    Unless I clear my cache constantly, I get either an "invalid url" error or an "oops, no such page error"--sometimes an incomplete Web page. == URL of affected sites == many, some of which are new to me

  • Database design for swapping/trading items between companies

    What is the best SQL table schema for items being swapped/traded between companies? For instance: e.g.1 If company A wants to swap item 0001 (owned by customer X but being managed by company A) with company B who is offering item 0002 (owned by custo

  • Printing chart with legend type "DATATABLE" only shows graph.

    Hi All, We are running BI 7.01, distributing webtemplates via the Portal. When a report contains a chart with Legend Type "DATATABLE", the table under the graph does not get printed when creating a PdF print. The report output shows the data fine. Ho

  • Can't sign in to version 7.1.0.105

    Been using Skype for years and all worked fine on Friday. Working fine on ipad (with my new password) but I was unable to sign into desktop version this morning (use it all day for work!). I have tried uninstalling and reinstalling and the version it