Query Using Group Problem

I have a table like the example below. I am looking to get
the results like the example - I have included my code that I have
this far, but it is not giving me the right results.
Can someone point me in the right direction?
This is what I want it to do:
orders table
orderid | vendor | product | color | size
1 | sammoon | watch | silver | Large
2 | beckam | necklace | silver | Medium
3 | sammoon | watch | silver | large
4 | sammoon | watch | gold | Medium
5 | beckam | necklace | gold | medium
6 | switse | ring | gold | small
7 | sammoon | earring | silver | small
8 | switse | ring | gold | medium
9 | beckam | necklace | gold | small
10 | switse | necklace | platinum | large
Results for Report
Sammoon
watch
Large
1 - Silver
3 - Silver
Medium
4 - Gold
earrings
Small
7 - silver
Beckam
Necklace
Medium
2 - silver
5 - gold
Small
9 - gold
Switse
Ring
Medium
8 - gold
Small
6 - gold
Necklace
Large
10 - platinum
This is my current code (note: not exactly like example but
same principle):
<CFOUTPUT>
<CFQUERY name="q1" datasource="#DSN#" username="#USER#"
password="#PASS#">
SELECT avendor,orderid
FROM smorders s
WHERE orderstatus='released to production'
Group By avendor,orderid
Order By avendor
</CFQUERY>
<CFLOOP query="q1">
#q1.avendor#<BR>
<CFQUERY name="q2" datasource="#DSN#" username="#USER#"
password="#PASS#">
SELECT vasku,shortdesc
FROM smorders s
WHERE avendor='#q1.avendor#'
Group By vasku,shortdesc
Order By vasku
</CFQUERY>
<CFLOOP query="q2">
    #vasku# -
#q2.shortdesc#<BR>
<CFQUERY name="q3" datasource="#DSN#" username="#USER#"
password="#PASS#">
SELECT color
FROM smorders
WHERE avendor='#q1.avendor#'
GROUP BY color
ORDER BY color
</CFQUERY>
<CFLOOP query="q3">
             #q3.color#<BR>
<CFQUERY name="q4" datasource="#DSN#" username="#USER#"
password="#PASS#">
SELECT size,orderid
FROM smorders
WHERE avendor='#q1.avendor#' and orderid=#q1.orderid#
GROUP BY size,orderid
ORDER BY size
</CFQUERY>
<CFLOOP query="q4">
                 Order
##: #q4.orderid# - Size: #q4.size#<BR>
</CFLOOP>
</CFLOOP>
</CFLOOP>
</CFLOOP>
</CFOUTPUT>
Anyone? Thanks in advance.

No need for all those nested queries. If I'm understanding
correctly, you only need 1 query and a series of nested cfoutput
statements. Use an ORDER BY clause to order the results the way you
want them grouped.
Sammoon (By Vendor)
watch (then by Product)
Large (then by Size)
1 - Silver (then by Color) (and finally by OrderId)
3 - Silver
Medium
4 - Gold
earrings
Small
7 - silver
So your SQL clause would be: ORDER BY Vendor, Product, Size,
Color then OrderId. Finally use nested cfoutput statements to group
the output. See the attached example
I noticed your table contains duplicated data. If that is the
actual table structure you should consider normalizing to eliminate
the duplication. You should have a separate table for the distinct
Products, Colors, Sizes and Vendors and the orders table should
store the id's not the names.
Table | Columns
Product | ProductID, ProductName
Vendor | VendorID, VendorName
Color | ColorID, ColorName
Size | SizeID, SizeName
SMOrders | OrderId, ProductID, VendorID, ColorID, SizeID

Similar Messages

  • Sqlserver query using Group by and Order by

    SUM(BILL_DETAIL.x_bill_quantity) as BILL_QUANTITY,
    MIN(BILL_DETAIL.x_billable_to) as BILLABLE_TO,
    MIN(BILL_DETAIL.x_billable_yn) as BILLABLE_YN,
    AVG(BILL_DETAIL.x_bill_rate) as BILL_RATE,
    MIN(BILL_DETAIL.x_cost_rate) as COST_RATE,
    MIN(BILL_DETAIL.x_cost_total) as COST_TYPE,
    LISTAGG(BILL_DETAIL.objid, ',') WITHIN GROUP(ORDER BY BILL_DETAIL.objid) as ID_LIST
    FROM table_x_gsa_bill_detail BILL_DETAIL
    WHERE (1=1)
    GROUP BY (DECODE(BILLABLE_YN, 1, 'Billable', 'Non-Billable') || ',' || BILLABLE_TO || ',' || DETAIL_CLASS || ',' || COST_TYPE || ',' || BILL_RATE)
    ORDER BY DECODE(BILLABLE_YN, 1, 'Billable', 'Non-Billable') || ',' || BILLABLE_TO || ',' || DETAIL_CLASS ||
    ) dt WHERE rn BETWEEN 0 AND 1
    Can any one pls help me using of Case Condition keyword instead of Decode in the above query ??? iam not able to convert above query for group by and order by..
    Actually i need to do group by the aggragate values which i got the values from the fields of BILLABLE_YN,BILLABLE_TO,DETAIL_CLASS, COST_TYPE, BILL_RATE.
    where as in oracle i can run above query using decode keyword where as in sqlserver iam not able to use BILLABLE_YN field alias of above query in group by .
    i tried like by using following way but it is wrong because here iam not using aggragate values of fields in group by funtion please help me in converting query in sqlserver. GROUP BY (case BILLABLE_YN when 1 then 'Billable' when 0 then 'Non-Billable' else
    'Non-Billable' End BILLABLE_YN + ',' + BILLABLE_TO + ',' + DETAIL_CLASS + ',' + COST_TYPE + ',' + BILL_RATE)
    Krishna

    CREATE TABLE DETAIL
    ([objid] int,[x_billable_to] varchar(19), [x_bill_quantity] int,
    [x_billable_yn] int, [x_bill_rate] int, [COST_TYPE] varchar(19) )
    INSERT INTO
    DETAIL
    ([objid], [x_billable_to], [x_bill_quantity], [x_billable_yn], [x_bill_rate],[COST_TYPE])
    VALUES
    (1, 'Customer', 3, 1, 20,'Parking'),
    (2, 'Customer', 1, 1, 25,'Toll'),
    (3, 'Customer', 2, 1, 20,'Parking') 
    Pls convert following query for executing query in sqlserver  ..for the column ID_List it should return data like 1,2,3
    SELECT * FROM (SELECT 1 rn,
            SUM(BILL_DETAIL.x_bill_quantity)      as BILL_QUANTITY,
            MIN(BILL_DETAIL.x_billable_to)        as BILLABLE_TO,
            MIN(BILL_DETAIL.x_billable_yn)        as BILLABLE_YN,
            AVG(BILL_DETAIL.x_bill_rate)          as BILL_RATE,
            LISTAGG(BILL_DETAIL.objid, ',') WITHIN GROUP(ORDER BY BILL_DETAIL.objid) as ID_LIST
         FROM   BILL_DETAIL
          WHERE (1=1)
     GROUP BY (DECODE(x_billable_yn, 1, 'Billable', 'Non-Billable') + ',' + x_billable_to  +  ',' + COST_TYPE + ',' + x_bill_rate)
          ORDER BY DECODE(x_billable_yn, 1, 'Billable', 'Non-Billable') + ',' + x_billable_to  +  ',' + COST_TYPE + ',' + x_bill_rate
           )dt 
    WHERE rn BETWEEN 0 AND 1
    Krishna
    sounds like this
    SELECT *
    FROM
    SELECT 1 rn,
    SUM(BILL_DETAIL.x_bill_quantity) as BILL_QUANTITY,
    MIN(BILL_DETAIL.x_billable_to) as BILLABLE_TO,
    MIN(BILL_DETAIL.x_billable_yn) as BILLABLE_YN,
    AVG(BILL_DETAIL.x_bill_rate) as BILL_RATE,
    LEFT(bd1.ID_LIST,LEN(bd1.ID_LIST)-1) AS ID_Listing
    FROM BILL_DETAIL bd
    CROSS APPLY (
    SELECT BILL_DETAIL.objid + ',' AS [text()]
    FROM BILL_DETAIL
    WHERE objid = bd.objid
    FOR XML PATH('')
    )bd1(ID_LIST)
    WHERE (1=1)
    GROUP BY (CASE WHEN x_billable_yn = 1 THEN 'Billable' ELSE 'Non-Billable'END + ',' + x_billable_to + ',' + COST_TYPE + ',' + x_bill_rate),
    LEFT(bd1.ID_LIST,LEN(bd1.ID_LIST)-1)
    ORDER BY (CASE WHEN x_billable_yn = 1 THEN 'Billable' ELSE 'Non-Billable'END + ',' + x_billable_to + ',' + COST_TYPE + ',' + x_bill_rate),
    LEFT(bd1.ID_LIST,LEN(bd1.ID_LIST)-1)
    )dt
    WHERE rn BETWEEN 0 AND 1
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • SQL query using Group by and Aggregate function

    Hi All,
    I need your help in writing an SQL query to achieve the following.
    Scenario:
    I have table with 3 Columns. There are 3 possible values for col3 - Success, Failure & Error.
    Now I need a query which can give me the summary counts for distinct values of col3 for each GROUP BY of col1 and col2 values. When there are no values for col3 then it should return ZERO count.
    Example Data:
    Col1 Col2 Col3
    abc 01 success
    abc 02 success
    abc 01 success
    abc 01 Failure
    abc 01 Error
    abc 02 Failure
    abc 03 Error
    xyz 07 Failure
    Required Output:
    c1 c2 s_cnt F_cnt E_cnt (Heading)
    abc 01 2 1 1
    abc 02 1 1 0
    abc 03 0 0 1
    xyz 07 0 1 0
    s_cnt = Success count; F_cnt = Failure count; E_cnt = Error count
    Please note that the output should have 5 columns with col1, col2, group by (col1,col2)count(success), group by (col1,col2)count(failure), group by (col1,col2)count(error)
    and where ever there are NO ROWS then it should return ZERO.
    Thanks in advance.
    Regards,
    Shiva

    Hi,
    user13015050 wrote:
    Thanks TTT. Unfortunately I cannot use this solution because I have huge data for this.T's solution is basically the same as mine. The first 23 lines just simulates your table. Since you actually have a table, you would start with T's line 24:
    SELECT col1 c1, col2 c2, SUM(decode(col3, 'success', 1, 0)) s_cnt, ...
    user13015050 wrote:Thanks a lot Frank. It helped me out. I just did some changes to this as below and have no issues.
    SELECT     col1
    ,     col2
    ,     COUNT ( CASE
              WHEN col3 = 'SUCCESS'
              THEN 1
              END
         )          AS s_cnt
    ,     COUNT ( CASE
              WHEN col3 = 'FAILED'
              THEN 1
              END
         )          AS f_cnt
    ,     COUNT ( CASE
              WHEN col3 = 'ERROR'
              THEN 1
              END
         )          AS e_cnt
    FROM     t1
    WHERE c2 in ('PURCHASE','REFUND')
    and c4 between to_date('20091031000000','YYYYMMDDHH24MISS') AND to_date('20100131235959','YYYYMMDDHH24MISS')
    GROUP BY c1, c2
    ORDER BY c1, c2;
    Please let me know if you see any issues in this query.It's very hard to read.
    This site normally compresses spaces. Whenever you post formatted text (such as queries or results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    Also, post exactly what you're using.  The code above is SELECTing col1 and col2, but there's no mention of either in the GROUP BY clause, so I don't believe it's really what you're using.
    Other than that, I don't see anything wrong or suspicious in the query.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Query using Group by - help needed

    I am having a query as follows:
    select id_nbr, stop_nbr, street || city || state, count(sub_stop_nbr)
    from details where created_date = ' 22-Jul-08';
    As group by clause is missing it is giving errors.
    But when I add group by to this query, I have to add all selected values.
    How can I add the concatenatd values here.
    Is there any other way rather than writing as :
    (select id_nbr, stop_nbr, street || city || state, count(sub_stop_nbr)
    from details where created_date = ' 22-Jul-08'
    group by id_nbr, stop_nbr, street || city || state)

    so where is the problem in writing:
    select id_nbr, stop_nbr, street || city || state, count(sub_stop_nbr)
    from details
    where created_date = ' 22-Jul-08'
    group by id_nbr, stop_nbr, street || city || state
    ????

  • Error using group by expression

    hello friends,
    I use this query & used group by but oracle give error :
    ORA-00979: not a GROUP BY expression
    Select uu.ID,max(uu.module_name) as MainMenu,uu.NAME,decode(substr(param_str,4,1), 'P','ü','') as Allow,decode(substr(param_str,1,1), 'A','ü','') as Ins,decode(substr(param_str,2,1), 'E','ü','') as Edit,decode(substr(param_str,3,1), 'D','ü','') as Del from USER_MODULE uu,user1 where( user_name='SA'or user_name is null)and user1.srno=uu.srno and uu.ID=uu.ID group by uu.id,uu.name,MainMenu group by uu.id,uu.name

    Hi
    The 'param_str' in DECODE function either should be a bind variable for user input or should be a column of a table. If it is a table/view column then include it in the GROUP BY clause and the query should work.
    If you specify a GROUP BY clause in a statement, then the select list can
    contain only the following types of expressions:
    – GROUP BY expressions
    – Constants
    – Aggregate functions and the functions USER, UID, and SYSDATE
    – Expressions identical to those in the group_by_clause. If the group_by_
    clause is in a subquery, then the GROUP BY columns of the subquery must
    match the select list of the outer query. Any columns in the select list of the
    subquery that are not needed by the GROUP BY operation are ignored without
    error.
    – Expressions involving the preceding expressions that evaluate to the same
    value for all rows in a group
    In short, except for the columns in aggregate functions, all columns must be included in the GROUP BY clause.
    - Priya

  • How to write a SQL Query without using group by clause

    Hi,
    Can anyone help me to find out if there is a approach to build a SQL Query without using group by clause.
    Please site an example if is it so,
    Regards

    I hope this example could illuminate danepc on is problem.
    CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
    CREATE OR REPLACE FUNCTION GET_ARR return my_array
    as
         arr my_array;
    begin
         arr := my_array();
         for i in 1..10 loop
              arr.extend;
              arr(i) := i mod 7;
         end loop;
         return arr;
    end;
    select column_value
    from table(get_arr)
    order by column_value;
    select column_value,count(*) occurences
    from table(get_arr)
    group by column_value
    order by column_value;And the output should be something like this:
    SQL> CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
      2  /
    Tipo creato.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION GET_ARR return my_array
      2  as
      3   arr my_array;
      4  begin
      5   arr := my_array();
      6   for i in 1..10 loop
      7    arr.extend;
      8    arr(i) := i mod 7;
      9   end loop;
    10   return arr;
    11  end;
    12  /
    Funzione creata.
    SQL>
    SQL>
    SQL> select column_value
      2  from table(get_arr)
      3  order by column_value;
    COLUMN_VALUE
               0
               1
               1
               2
               2
               3
               3
               4
               5
               6
    Selezionate 10 righe.
    SQL>
    SQL> select column_value,count(*) occurences
      2  from table(get_arr)
      3  group by column_value
      4  order by column_value;
    COLUMN_VALUE OCCURENCES
               0          1
               1          2
               2          2
               3          2
               4          1
               5          1
               6          1
    Selezionate 7 righe.
    SQL> Bye Alessandro

  • Querying user groups while using @RunAs on a bean

    Hi,
    I am trying to implement a scenario in which I have three entities:
    - bean A - datastore for all users
    - bean B - implementing logic, filtering results from datastore for specific user based on groups he is in
    - User - calling bean B
    Calling chaing is User -> bean B -> bean A.
    bean B has to query user groups and filter data based on that. I've implemented that using:
    Subject subject = Security.getCurrentSubject();
    for (Principal principal : subject.getPrincipals()) {
    if (principal instanceof WLSGroup) {
    Without any security specified (like @RolesAllowed) it works like charm.
    But I want to add security constraints to the beans:
    @RolesAllowed("admin")
    class A {}
    @RolesAllowed("user")
    class B {}
    The problem is that B cannot acces A methods because it is calling A using 'user' security context.
    I've thought I change it to:
    @RunAs("application")
    @RolesAllowed("user")
    class B {}
    "Application" is an account in group admin.
    Now B can call A. The problem is that security context is switched to "application" on entering B's methods. Inside them I cannot query user groups using method presented above, because I get "application" groups.
    Is there a way to change security context on calling other bean methods? Like using Security.runAs( somehowGetApplicationSubject(), runnable) ??
    Other method I've thought of, but I have no idea how to implement that, is somehow querying weblogic to get groups of SessionContext.getCallerPrincipal(), which returns user account regardless of using RunAs.
    Hope someone made through this problem before,
    Krzysiek

    getBounds() will only generally make sense while the component itself is being rendered. I wouldn't be completely surprised if the framework which gets that component also resets its size once it's done painting the thing.
    If you're calling it from outside the rendering loop, perhaps you could try calling validate() on the component, which should force it to determine its size.
    Failing that, you could possible use getPreferredSize() instead, which will likely obtain a similar result in most cases.

  • Problem executing a partition query using occi in c++

    i am trying to execute a simple select query which returns a row from the table. The query is
    m_stmt->setSQL("select * from table partition(:1) where mdn = :2");
              m_stmt->setString(1,"P9329");
              //m_stmt->setInt(2,9320496213);
              ResultSet * rs = m_stmt->executeQuery();
              while(rs->next())
              cout<<"the value of preferences is aaaaaaaaaaaa"<< rs->getString(3);                    
    The problems that i am facing are as follows :
    1) if i execute the query using the actual values in the select query, it seems to be working fine, but when i try the above method to make it more dynamic (the values shown would be replaced by variables) it is giving me the following errors :
    a)if i put the partition value as a position parameter and put the mdn as the direct value in the query then it says the SQL command not ended properly
    b) if i put the partition value directly and put the mdn as a position parameter then the error is "Invalid Character "
    Any help would be much appreciated..ty in advance

    Hi Leonard,
    Thanks for letting me know that...thats pretty disappointing. Looks like I'll have to change my strategy in my implementation.
    Do you know if I can also develop functions using Acrobats SDK library methods such as "PDDocCreate()", "PDDocSave", etc. in OLE [MFC] applications?
    The reason why I ask is because I have previously created a plugin that creates a PDF file and embeds a 3D annotation... so this would be the same sort of idea that the 3D Tool Menu Item achieves.
    Now, if I were to use the function code within my OLE application, I will have to also include the PIMain.c file in my project as well correct?
    I hope this idea is a good one... please let me know if this approach is possible.
    Thanks.

  • How to write sql query that display comma suppurated result using Group by

    Hi,
    I am having data like bellow ,
    Above result got from joining two tables VMTAGroupClient,VMTAipNames .
    Query i have written to display above result is,
    select vgc.VMTAGroupId,vn.VMTAName from VMTAGroupClient vgc inner join VMTAipNames vn
    on vgc.VMTAID=vn.VMTANameID group by vgc.VMTAGroupId,vn.VMTAName 
    using the VMTAGroupId column how to write query to display result result like,
    VMTAGroupID    VMTAs
       1                       VMTA1,VMTA3
       2                       VMTA2,VMTA4,VMTA5
    Regards,
    Anwar Shaik

    Satheesh,
    Here in my case data need to read from two tables VMTAGroupClient, VMTAipNames.
    VMTAGroupId is in one table and VMTAName column in some other table.Iin both the tables VMTAID is common.
    Please check the above result displayed data from two tables.
    can we write same query using join?
    Anwar Shaik

  • Problems  while execution of query  using RSRT tcode

    Hi Experts,
    I have built a query in development server and I  have executed the query using RSRT tcode.I found some of the fields were having cross marks.Again I checked the no of records coming from infoprovider for that field.Data was coming from the cube.But I cant understand why for those particular fields cross mark were coming.Is it an issue?if it is an issue please tell me how to sort out.
    Regards
    Rakesh

    Hi Durgesh,
    First of all the field for which I got X symbol is not a selection criteria field.Rather it is an naviagational attribute of a characteristics.In my query service order is a charecterictreristics and status type is an attribute of it.I am  checking the status type of different orders.For a particular order and status tupe X symbol is coming.
    Regards
    Rakesh

  • Error while using Group By on 2 Querys joined by union

    Hello Everyone
    I have a situation where in one report i cannot group the data and in another report when i group the data i am unable to view subject area.
    I Had a Complex Request from my client , i have to claculate a report based on 2 dimensions i.e i am calculating 2 measures from one dimension and other 3 measures from other dimension and then using UNION to join both the querys , for the same description the data is being displayed in 2 rows , then i i tried to combine both the querys from union and trying to select from those then i am getting the result and the problem is i am unable to access the subject area , its giving "Either you do not have permission to use the subject area within Answers, or the subject area does not exist." Error , i am unable to add prompts to these request
    I want the investor Grants Row to be displayed in one Column , I am already using Group by in one of the querys.
    Study                      Cost            Approved         Committed                 Earned          Paid Balance
    Investigator Grants 350,000.00 113,770.78 0.00 0.00 0.00
    Investigator Grants 350,000.00 113,770.78 42,403.13 19,905.90 22,497.23
    Labs 23,000.00 0.00 0.00 0.00 0.00
    Study Drug 47,000.00 0.00 0.00 0.00 0.00
    Other 0.00 0.00 0.00 0.00 0.00
    Here is my query
    SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration"."Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, SUM (IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) BY "- Administration"."Study Cost" ) saw_11, SUM(IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_12, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_13, SUM(IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_14, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0)-IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248') UNION SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration". "Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) saw_11, IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) saw_12, 0.00 saw_13, 0.00 saw_14, 0.00 saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Protocol"."Protocol #" = 'P31248') AND ("- Administration". "Display Currency Code" = 'USD') ORDER BY saw_16 DESC
    Any help is appreciated ..!
    ~Srix

    Here is the query i used to group the data but i cannot access Answers with this query
    SELECT saw_0 saw_0, saw_1 saw_1, saw_2 saw_2, saw_3 saw_3, saw_4 saw_4, saw_5 saw_5, saw_6 saw_6, saw_7 saw_7, saw_8 saw_8, saw_9 saw_9, saw_10 saw_10, SUM(saw_11 BY saw_10) saw_11, SUM(saw_12 BY saw_10 ) saw_12, SUM(saw_13 BY saw_10) saw_13, SUM(saw_14 BY saw_10) saw_14, SUM(saw_15 BY saw_10) saw_15, saw_16 saw_16 FROM (SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration"."Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, SUM (IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) BY "- Administration"."Study Cost" ) saw_11, SUM(IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_12, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_13, SUM(IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_14, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0)-IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248') AND ("- Payment"."Payment Number"="- Payment"."Related Payment Request Number")
    UNION SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration". "Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) saw_11, IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) saw_12, 0.00 saw_13, 0.00 saw_14, 0.00 saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248')) T GROUP BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7, saw_8, saw_9, saw_10 , saw_11, saw_12, saw_13, saw_14, saw_15, saw_16 ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6

  • Query using binding help?!?!

    I am fairly new to the world of SQL and I am having a problem with a query using binding. I am using SQL Developer (3.1.07).
    If I run the query with no bindings, everything works fine. On normal occasions I run this query on the day I want my totals and I achieve my desired results:
    SELECT SA.CRAFT,nvl(SUM (SA.LABORHRS),0) as "Loaded Hours"
    FROM SOL_SCHEDULEBASELINEWOASGMNT SA
    LEFT JOIN SOL_SCHEDULEBASELINE SB ON SB.BASELINEID = SA.BASELINEID
    WHERE SB.DATECODE = 'DAILY'
    AND TO_CHAR(SB.FROMDATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    AND TO_CHAR(SB.TODATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    AND TO_CHAR(SA.SCHEDULEDATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    group by sa.craft
    order by sa.craft asc
    CRAFT     Loaded Hours
    CONTR.     24
    MM     12
    MT     6
    BUT* I want to be able to enter my own date instead of using sysdate. This will be for if I miss running this for a day, am asked for the values from a previous date, etc...
    The value will always be the same date for all three date fields(SB.FROMDATE,SB.TODATE,SA.SCHEDULEDATE)
    I've modified the query to here and the query still works great at this stage: (I'm using 01-APR-2012 in my binding...)
    SELECT SA.CRAFT,nvl(SUM (SA.LABORHRS),0) as "Loaded Hours"
    FROM SOL_SCHEDULEBASELINEWOASGMNT SA
    LEFT JOIN SOL_SCHEDULEBASELINE SB ON SB.BASELINEID = SA.BASELINEID
    WHERE SB.DATECODE = 'DAILY'
    AND SB.FROMDATE = :DDMONYYYY
    AND SB.TODATE = :DDMONYYYY
    AND TO_CHAR(SA.SCHEDULEDATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    group by sa.craft
    order by sa.craft asc
    CRAFT     Loaded Hours
    CONTR.     24
    MM     12
    MT     6
    The instant I change my query to the following I get a different result:
    SELECT SA.CRAFT,nvl(SUM (SA.LABORHRS),0) as "Loaded Hours"
    FROM SOL_SCHEDULEBASELINEWOASGMNT SA
    LEFT JOIN SOL_SCHEDULEBASELINE SB ON SB.BASELINEID = SA.BASELINEID
    WHERE SB.DATECODE = 'DAILY'
    AND SB.FROMDATE = :DDMONYYYY
    AND SB.TODATE = :DDMONYYYY
    AND SA.SCHEDULEDATE = :DDMONYYYY
    group by sa.craft
    order by sa.craft asc
    CRAFT     Loaded Hours
    CONTR.     10
    All columns have a data_type of Date.
    As soon as I change SA.SCHEDULEDATE from
    AND TO_CHAR(SA.SCHEDULEDATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    to
    SA.SCHEDULEDATE = :DDMMYYYY
    it stops returning the results I need.
    Why is this? Does anyone have an idea of what is going on here? Any help would be GREATLY appreciated!
    Thank You

    Cook wrote:
    I am fairly new to the world of SQL and I am having a problem with a query using binding. I am using SQL Developer (3.1.07).
    If I run the query with no bindings, everything works fine. On normal occasions I run this query on the day I want my totals and I achieve my desired results:
    SELECT SA.CRAFT,nvl(SUM (SA.LABORHRS),0) as "Loaded Hours"
    FROM SOL_SCHEDULEBASELINEWOASGMNT SA
    LEFT JOIN SOL_SCHEDULEBASELINE SB ON SB.BASELINEID = SA.BASELINEID
    WHERE SB.DATECODE = 'DAILY'
    AND TO_CHAR(SB.FROMDATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    AND TO_CHAR(SB.TODATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    AND TO_CHAR(SA.SCHEDULEDATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    group by sa.craft
    order by sa.craft asc
    CRAFT     Loaded Hours
    CONTR.     24
    MM     12
    MT     6
    BUT* I want to be able to enter my own date instead of using sysdate. This will be for if I miss running this for a day, am asked for the values from a previous date, etc...
    The value will always be the same date for all three date fields(SB.FROMDATE,SB.TODATE,SA.SCHEDULEDATE)
    I've modified the query to here and the query still works great at this stage: (I'm using 01-APR-2012 in my binding...)
    SELECT SA.CRAFT,nvl(SUM (SA.LABORHRS),0) as "Loaded Hours"
    FROM SOL_SCHEDULEBASELINEWOASGMNT SA
    LEFT JOIN SOL_SCHEDULEBASELINE SB ON SB.BASELINEID = SA.BASELINEID
    WHERE SB.DATECODE = 'DAILY'
    AND SB.FROMDATE = :DDMONYYYY
    AND SB.TODATE = :DDMONYYYY
    AND TO_CHAR(SA.SCHEDULEDATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    group by sa.craft
    order by sa.craft asc
    CRAFT     Loaded Hours
    CONTR.     24
    MM     12
    MT     6
    The instant I change my query to the following I get a different result:
    SELECT SA.CRAFT,nvl(SUM (SA.LABORHRS),0) as "Loaded Hours"
    FROM SOL_SCHEDULEBASELINEWOASGMNT SA
    LEFT JOIN SOL_SCHEDULEBASELINE SB ON SB.BASELINEID = SA.BASELINEID
    WHERE SB.DATECODE = 'DAILY'
    AND SB.FROMDATE = :DDMONYYYY
    AND SB.TODATE = :DDMONYYYY
    AND SA.SCHEDULEDATE = :DDMONYYYY
    group by sa.craft
    order by sa.craft asc
    CRAFT     Loaded Hours
    CONTR.     10
    All columns have a data_type of Date.
    As soon as I change SA.SCHEDULEDATE from
    AND TO_CHAR(SA.SCHEDULEDATE, 'DD-MON-YYYY') = TO_CHAR(SYSDATE, 'DD-MON-YYYY')
    to
    SA.SCHEDULEDATE = :DDMMYYYY
    it stops returning the results I need.
    Why is this? Does anyone have an idea of what is going on here? Any help would be GREATLY appreciated!
    Thank YouWhat are the datatypes involved?
    It is likely that you are being impacted by implicit datatype conversion.
    Realize that you can only enter strings; so you need to use TO_DATE() to convert string to DATE.

  • Query using Infoset (NW04s)

    I have an infoset based on a CUBE & DSO. I create a query on Infoset. The query uses 0GL_ACCOUNT and uses a hierarchy. In the query result, there are instances where the a G/L account amount does not roll up to the associated hierarchy node.
    Example
    GL Node 1 -
    $0.00
    GL Acct----
    $500.00
    I don't get this problem when I run a similar query on CUBE.

    Hi Rajesh,
    There will be two querry areas, check in which area you have created Infoset and user group. You will find the combination in relevant query area only.
    Two area are
    Standard Area (Client-specific)
    Global Area (Cross-client)
    Thanks
    ANAND K

  • Conditions on a Query using Nav. Attr. (quick reply is very appreciated).

    Hi experts,
    I have a problem here with a query using both conditions and navigation attributes.
    The problem is as follow:
    I created a query with ZPRDGRP (product group), ZPRDTYPE (product type), ZPRDVAR (product variant) and 0MATERIAL (material), 0EXTMATLGRP (external material group) on the row side.
    On the column side, I have several restricted Key Figures:
    PriceA, PriceB and Quantity.
    The 0EXTMATLGRP is a <u>navigation attribute</u> of the 0MATERIAL.
    I created a conditions whereby I only want to see the materials with PriceA=0.
    But everytime I tried to run the query on the web, I always get this error message:
    "Termination message sent
    ABEND RSBOLAP (000): Program error in class SAPMSSY1 method : UNCAUGHT_EXCEPTION
      MSGV1: SAPMSSY1
      MSGV3: UNCAUGHT_EXCEPTION"
    The error message always occurs everytime I include the 0EXTMATGRP on my rows. If I remove this, then my query will work fine. But I need to include this 0EXTMATGRP on my query.
    Furthermore, this error message just occurs if I run the query on the web, but if I just run it on the analyzer, then it also just work totally fine.
    Has anyone encounter this problem before? Is this a bug? How to solve this problem?
    Thank you a lot in advance!
    Fen.

    Hi all, I have found a solution for this one.
    I think it should be a bug, since if I included the Product Size characteristics in it (even though I hide it), then the query will work fine.

  • Assign SQ03 Abap Query User Group to role

    Please advise how to assign SQ03 Abap Query User Group to a role. Thanks.
    Moderator message: please do more research before asking.
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers]
    Edited by: Thomas Zloch on May 12, 2011 5:40 PM

    Hello Sunil,
    The problem is that I have hundreds of users to maintain user groups.
    found out that it is possible to assign user group to role and role to user groups. implementing hr authorization with in-direct assignment of auth. So if I could use sq10, user groups could also be link to position in the org chart.
    sq10 does allow you to assign a user group to a role but when you assign the role to a user and the user runs a query, it reports that no user group has been assigned.
    Suspect that there must be a parameter or switch that is not turned on
    Regards

Maybe you are looking for

  • OIM 9.1.0.2 patch: not able to create user.

    Hi, After the 9.1.0.2 patch installation I am not able to create users. The following exception is thrown: DOBJ.THROWABLE_IN_SAVE Unhandled throwable java.lang.IllegalAccessError in com.thortech.xl.dataobj.tcUSR's save. help required..

  • The buttons in the list are disabled

    Hi Experts, I want to create a list uibb.  Have embedded the customized list in the standard form. I have used the standard BOFU class as the feeder class /BOFU/CL_FBI_GUIBB_LIST. Added two standard buttons FBI_CREATE and FBI_DELETE, but these both b

  • How to set an tabbed page value in a field on another page?

    Hi, I am creating an Application in jdev10.3.4 ADF.i have created a tabbed page having 4 tabs Leeson Learned Best Practice Value Addition Other on each tabbed page i have a create button which will open a create page on that create page i need to set

  • Insert in Java via Microsoft Access

    Hello People I need insert into DataBase datas with app in Java and DataBase Microsoft Access. How insert in Microsoft Access with app Java? Witch the Syntax of the SQL for Microsoft Access with app Java? Thanks Richard Java/Oracle Programmer

  • Assertion failed error on oracle 9i Dev.Suite

    hi, I installed oracle 9i Dev. Suite but I cannot start forms builder & Reports developer as it says assertion failed-line 428: on microsoft visual c++ runtime library dialog. when i ignore it shuts down. i have forms 6i on a different oracle home an