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
????

Similar Messages

  • Need SQL query using View - Please help

    Hi,
    I have similar requirement like below.
    I have two tables DEPT and EMP and some departments may not have employees. I have created below view, which displays all DEPT records, even though there are no emplyees.
    CREATE OR REPLACE VIEW dept_emp_vw AS
    SELECT deptno, empid, 0 AS selected
    FROM dept d, emp e
    WHERE d.deptno = e.deptnno (+);
    Ex.
    DEPTNO         EMPID        SELECTED
    10 101 0
    10 102 0
    20 103 0
    30 103 0
    40 104 0
    50 <null> 0
    Application will pass "empid" to the view (for ex. empid = 103) and I want result like below.
    Ex.
    DEPTNO         EMPID        SELECTED
    10 101 0
    10 102 0
    20 103 1
    30 103 1
    40 104 0
    50 <null> 0
    Can you please let me know the query using "dept_emp_vw" view. We have Oracle 11g Release 2.
    Thanks a lot for the help.

    Not possible using normal SQL - as SQL is not a procedure language and does not support variable declaration and use (e.g. passing empid as a variable and using it both as a predicate and as a condition in the SQL projection).
    That said - SQL can be "+parameterised+". An approach that is ugly and contrary to the basic design and use of SQL. But it can support the (very weird) view definition of yours.
    E.g.
    SQL> create or replace procedure SetVariable( name varchar2, value varchar2 ) is
      2  begin
      3          DBMS_SESSION.set_context( 'MyVariables', name, value );
      4  end;
      5  /
    Procedure created.
    SQL>
    SQL>
    SQL> create or replace context MyVariables using SetVariable;
    Context created.
    SQL>
    SQL> create or replace view my_funky_weird_view as
      2  select
      3          e.empno,
      4          e.ename,
      5          e.job,
      6          case e.empno
      7                  when to_number(sys_context( 'MyVariables', 'empid' )) then
      8                          0
      9                  else
    10                          1
    11          end     as "SELECTED"
    12  from       emp e
    13  /
    View created.
    SQL>
    SQL> exec SetVariable( 'empid', 7499 )
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from session_context where namespace = 'MYVARIABLES';
    NAMESPACE            ATTRIBUTE            VALUE
    MYVARIABLES          EMPID                7499
    SQL>
    SQL> select * from my_funky_weird_view order by selected;
         EMPNO ENAME      JOB               SELECTED
          7499 ALLEN      SALESMAN                 0
          7521 WARD       SALESMAN                 1
          7566 JONES      MANAGER                  1
          7654 MARTIN     SALESMAN                 1
          7698 BLAKE      MANAGER                  1
          7934 MILLER     CLERK                    1
          7788 SCOTT      ANALYST                  1
          7839 KING       PRESIDENT                1
          7844 TURNER     SALESMAN                 1
          7876 ADAMS      CLERK                    1
          7900 JAMES      CLERK                    1
          7902 FORD       ANALYST                  1
          7369 SMITH      CLERK                    1
          7782 CLARK      MANAGER                  1
    14 rows selected.
    SQL>But I will N\OT recommend doing it this way. It is not natural SQL as PL/SQL is needed to "+inject+" name-value pairs into the context for the SQL view to use. It is ugly. It is not standard. It cannot scale. It is complex to use. Etc.
    Yes, there are instances when this approach is exactly what one needs - when for example dealing with a trusted context and using the contents for implementing a security layer. But in the above case - I would rather want to see the actual business requirement first, as I think you're barking up the wrong tree with the view solution you have imagined.

  • 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

  • Deploying Files with Group Policy - Help Needed

    Hi,
    I am trying to use group policy to deploy files and folders to our server estate. The policy I have created first creates a folder on each server's C drive and then coppies a set of files to this folder from a network share. The folder creation works fine
    but the files copy fails. In the Application logs on the servers it displays the following error:
    The computer 'ILMT' preference item in the 'GPO - Servers_Production_ALL {CC026B58-FA3B-4399-AA00-AE8E844B2B47}' Group Policy object did not apply because it failed with error code '0x80070005 Access is denied.' This error was suppressed.
    Can anyone advise what exactly does not have access here? I don't know what I need to enable to get this to work.
    Can anyone help?
    Many thanks
    James

    The copy is on a file server share. presumably if I just give everybody read access to the share that would suffice?
    No it won't.
    "Sharing" requires several actions:
    a) create the folder
    b) share the folder
    c) grant NTFS permissions on the folder
    I think you've neglected action (c).
    For your scenario, you need to grant the "server computers" read permissions to the folder.
    You can add individual computer accounts, or a group, or "domain computers".
    (In a similar way, you could grant access to a user, a group, or "domain users")
    [if you need everybody (users) *AND* everything (computers), you could grant permissions to "authenticated users" since that principal includes *BOTH* users and also computers]
    Note that "domain computers" and "authenticated users" include all types of domain member computers, i.e. servers, workstations, etc.
    Also, note that granting a "computer account" access to a folder or share, does *NOT* mean that a user account on that computer can access the remote share, i.e. permission is granted to the computer account, and a logged-in user account on
    that computer does not inherit any kind of access to the remote share by virtue of being logged in.
    This means that the computer can access the share but the user cannot access the share. Because the computer account is an identity/principal of it's own accord.
    [None of which really has anything to do with Group Policy at all - it's how Windows does file sharing and ACLs... ;)
    Don
    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable.
    This helps the community, keeps the forums tidy, and recognises useful contributions. Thanks!)

  • 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Crosstab query using  PL/SQL [HELP]

    hi all,
    i got this output after execute my query:
    week no | department | item | budget
    1 | 0901 | salary | 25000
    1 | 0901 | stationery | 5000
    1 | 5501 | salary | 45000
    2 | 0901 | salary | 25000
    2 | 5501 | salary | 25000
    2 | 5501 | stationery | 100
    i hope to get the output like below:
    dept/week no 1 2 3
    =========================================
    0901 30,000 25,000 800 (A)
    5501 45,000 25,100 100 (B)
    variance 45,000 70,000 70,800 (C)
    =========================================
    Grand total - 75,000 - 50,100 - (D)
    ======================================
    NOTE:
    the week is from week 1 until week 52, is it advisable to use looping or??.
    It is more than 2 departments and items as well. the user is allowed to passing in more than 1 selection of the items (salary,stationary,hardware and software, etc) to get this report.
    I need to display the output on the screen/spool into file after the execution.
    ==========
    Definition
    ===========
    Grant total (D1) by week =(A1 + B1)
    Variance (C1) for the 1st week of the year will always take the (B1) values as the based values for the next calculation. whereas (C2) = (C1) + (A2) and (C3) =(C2)+(A3) and the same formular apply up to week 52.
    the pivot method not a suitable solution to produce this output.
    anyone can suggest the shorter and more intelligent solution?
    this is very urgent, pls help!! thank

    You can get your basic data by,
    SELECT department, week_no, sum(budget) AS budget
      FROM your_table
    GROUP BY department, week_no;Then you'll just pivot the above data by week. Then you can use an analytic SUM() to get your weekly totals.
    WITH your_table AS (
    SELECT '0901' AS department, 1 AS week_no, 1000 AS budget FROM dual
    UNION ALL
    SELECT '1234' AS department, 1 AS week_no, 500 AS budget FROM dual)
    SELECT v.*,
           SUM(budget) OVER (PARTITION BY week_no) AS week_total
      FROM (
    SELECT department, week_no, sum(budget) AS budget
      FROM your_table
    GROUP BY department, week_no
    ORDER BY department, week_no
           )  v;I have to admit I'm a bit confused about your definition of variance.

  • SQL Query Sorting Order issue - Help needed

    Hi All,
    I am using the following query in my project to display the records in the grid.
    /* Formatted on 04-09-2013 PM 8:01:51 (QP5 v5.149.1003.31008) */
      SELECT eol,
             status_msg,
             relation,
             building_name,
             device_id id,
             CEIL (SYSDATE - updated_date) duration,
             lab_id,
             aisle_id,
             aisle_location_id,
             ip_address,
             port,
             slot_num,
             hostname,
             pid,
             description,
             sl_num,
             eitms_code,
             status,
             dnd_flag,
             aisle,
             aisle_location,
             spname,
             os_version,
             user_id,
             TO_CHAR (updated_date, 'YYYY-MM-DD HH24:MI:SS') updated_date,
             isterm_svr,
             net_type,
             DEVICE_GROUP_REF,
             cmd_id_ref,
             LISTAGG (TESTBED_ID, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
                AS testbeds_id_ref,
             LISTAGG (NAME, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
                AS testbeds_names,
             spname || '-' || ip_address || '-' || port AS child_asset_group
        FROM DEVICE_TESTBED_VW
       WHERE lab_id IN
                ('7099849',
                 '10769617',
                 '4258712',
                 '10513562',
                 '10515074',
                 '5882676',
                 '8330925')
    GROUP BY eol,
             status_msg,
             relation,
             device_id,
             lab_id,
             aisle_id,
             aisle_location_id,
             ip_address,
             port,
             slot_num,
             hostname,
             pid,
             description,
             sl_num,
             eitms_code,
             status,
             dnd_flag,
             aisle,
             aisle_location,
             spname,
             os_version,
             user_id,
             updated_date,
             isterm_svr,
             net_type,
             DEVICE_GROUP_REF,
             cmd_id_ref,
             building_name
    ORDER BY building_name ASC,
             LOWER (child_asset_group) ASC,
             LOWER (relation) DESC
    The problem is , if any one sorting with any column  , the order is not correct
    In this below code , i have done sorting by port . But the result data order is not correct .
    /* Formatted on 04-09-2013 PM 8:07:02 (QP5 v5.149.1003.31008) */
      SELECT eol,
             status_msg,
             relation,
             building_name,
             device_id id,
             CEIL (SYSDATE - updated_date) duration,
             lab_id,
             aisle_id,
             aisle_location_id,
             ip_address,
             port,
             slot_num,
             hostname,
             pid,
             description,
             sl_num,
             eitms_code,
             status,
             dnd_flag,
             aisle,
             aisle_location,
             spname,
             os_version,
             user_id,
             TO_CHAR (updated_date, 'YYYY-MM-DD HH24:MI:SS') updated_date,
             isterm_svr,
             net_type,
             DEVICE_GROUP_REF,
             cmd_id_ref,
             LISTAGG (TESTBED_ID, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
                AS testbeds_id_ref,
             LISTAGG (NAME, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
                AS testbeds_names,
             spname || '-' || ip_address || '-' || port AS child_asset_group
        FROM DEVICE_TESTBED_VW
       WHERE lab_id IN
                ('7099849',
                 '10769617',
                 '4258712',
                 '10513562',
                 '10515074',
                 '5882676',
                 '8330925')
    GROUP BY eol,
             status_msg,
             relation,
             device_id,
             lab_id,
             aisle_id,
             aisle_location_id,
             ip_address,
             port,
             slot_num,
             hostname,
             pid,
             description,
             sl_num,
             eitms_code,
             status,
             dnd_flag,
             aisle,
             aisle_location,
             spname,
             os_version,
             user_id,
             updated_date,
             isterm_svr,
             net_type,
             DEVICE_GROUP_REF,
             cmd_id_ref,
             building_name
    ORDER BY PORT ASC
    Can some one help me to fix this issue?

    Hi,
    Sorry, it's not clear what you want.
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Simplify the problem as much as possible. For example, if you really need to GROUP BY 28 columns, post a problem where you need to GROUP BY only 2 or 3 columns.  (Just explain that you really have 28, so people will give solutions that are sure to work for all 28).)
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Active Directory Group Cleanup - Help Needed

    Hi All,
    I need to clean up our Active Directory and the first stage of this is to remove any unused groups. I have been trying to work out what these are using powershell. Can anyone please provide me with a simple powershell script that will identify any AD groups
    that have no members in them? 
    Many thanks
    James

    Greetings!
    Try this:
    import-module activedirectory
    Get-ADGroup –Filter * -Properties Members | where { $_.Members.Count –eq 0 }
    Regards.
    Mahdi Tehrani   |  
      |  
    www.mahditehrani.ir
    Please click on Propose As Answer or
    to mark this post as
    and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.
    How to query members of 'Local Administrators' group in all computers?
    Adding in: Watch out for users having customized groups (e.g groups other than Domain Users and Domain Admins) as their primary group, they will not be reflected in the member attribute and hence not be reflected in the above count, I know it's a rare case,
    but could be good to know.
    Enfo Zipper
    Christoffer Andersson – Principal Advisor
    http://blogs.chrisse.se - Directory Services Blog

  • 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

  • Query Using Joins.Please Help

    Hi,
    A Query please
    I have a Customer table and an Order Table
    The customer can place multiple orders
    Create Table Customers
    (Cust_id      number(2),
    cust_name    varchar2(15),
    constraint   pk_custid PRIMARY KEY(Cust_id)
    Create Table Orders
    (Order_no    number(2),
    Cust_id     number(2),
    order_status varchar2(1),
    constraint  pk_orderno PRIMARY KEY(order_no),
    constraint  fk_custid  FOREIGN KEY(cust_id)
    REFERENCES  Customers(cust_id)
    )Now,the Customer table has a single record
    whereas the Order Table has multiple records
    for the same customer.
    SQL> Select * from Orders
    ORDER_NO   CUST_ID ORDER_STATUS
            1         1 P
            2         1 PI'd like to view the different orders for that same customer
    Using a simple Join DOES NOT give the right output:
    SQL> Select C.cust_id,C.cust_name,
      2  O.order_no,O.order_status
      3  From Customers C,Orders O
      4  where C.cust_id = O.order_no;
      CUST_ID CUST_NAME        ORDER_NO O
            1 ABCD              1       PThere are 2 records in the Orders Table?
    How to view both the records from Orders Table?
    Do I need to use the EXISTS clause?
    Can someone please help?

    Well, I would have thought that you would join C.cust_id with the O.cust_id (and not O.order_no)???
    SQL> Select C.cust_id,C.cust_name,
      2  O.order_no,O.order_status
      3  From Customers C,Orders O
      4  where C.cust_id = O.order_no;

  • JPQL Query for specific usecase, help needed

    Does anyone knows how to write the JPQL query for this specific use case.
    Take 3 tables,
    Table 1 contains bids for many auctions (Bid table)
    Table 2 Contains many auctions (Auction Table)
    Table 3 contains many users (User Table)
    I need a query to retrieve all the highest bids per auction for a particular user.
    For example if the user has bidded on 10 auctions., but for each auctions has placed 3 bids each. Following the query, I would expect to get 10 bids back, each being the highest per auction.
    A Bid has a bid value that can be used for filtering.
    Thanks
    Peter

    It would be something like the JPQL version of 'select * from bids join auctions using (auction_id) where bids.userid = ? group by auctions.auction_id order by bids.amount desc'. But this is primarily an SQL question, and only secondarily a question as to how to translate that into JPQL, which should be straightforward.

  • Function Group - CUOV; Help needed

    Hi All,
    I am designing a Function module which will be used by a Variant function (LO-Variant configuration). The function Group CUOV has the list of standard function modules. But I am not bale to create successful test data for any of them. I had asked SAP to help me with the function Module documentation, but they said no since the function modules are not RELEASED.
    Now, If, any of you have worked with these function modules, please share your code/ideas.
    ~ Guru

    I think you'll have better luck with this question in the Discoverer forum.
    Discoverer

  • Output using Blackmagic HD - Help needed!

    I am trying to output via Decklink a DVCProHD 50 sequence and use the Blackmagic downconverter to get it on to DigiBeta. But when I try to tell FCP to use the same compressor for video playback the drop down doesn't give me a DVCProHD 50 option. Can anyone explain what I'm doing wrong and how I can get the sequence out before Monday !!
    Thanks in advance.

    Hey Jeremy
    Welcome to the forum.
    I'm not a work, so dare not claim catagorically, but could it be that DVCPRO HD 50 doesn't exist ?
    surely its either DVCPRO HD or DVCPRO 50 (i suppose the former might reasonably be called DVCPro100)
    if you're looking for DVCPRO 50 its often just called DV50, if you're looking for DVCPRO HD then make sure it isn't hiding behind a prefix like HDTV 1080 or HDTV 720 etc (you need to specify all this)
    hope it helps
    Andy

  • Between 31-180days  using Sysdate function -Help needed

    I am not getting any data in between 31 days and 180days in table
    Cust_lst_prch_dt :
    02/19/2009
    01/20/2009
    My query :
    select CUST_LST_PRCH_DT from order_table
    where CUST_LST_PRCH_DT>=trunc(sysdate)-31
    and CUST_LST_PRCH_DT<=trunc(sysdate)-180
    Please help me with my query
    Regards,
    clar

    Because you want it to be
    CUST_LST_PRCH_DT BETWEEN trunc(sysdate)-180 AND trunc(sysdate)-31?
    I'm guessing you mixed up your lower / upper boundary conditions in your query. However as i said, it's guessing since you've provided very little information.

  • Demoting a DC and Group policy, help needed.

    Hi all,
    so we have 3 domain controllers, lets say dc1,dc2 and dc3. We have the 3rd line assistance from another company, they have advised the following.... 
    SO the stages will be
    1) Can you please go through all the GPO's in DC3 and consolidate what you need and what you do not need, you need to extensively cross reference this with DC1 and DC2, this is something you have to do. As I will not know what you need and what you do
    not. You can do this by logging into each domain controller and opening up the settings of each GPO and cross referencing.
    2) Once the above is done, we will consolidate the GPO's to a central repository in your domain
    3) Backup Sysvol directory and Netlogon folder in DC3
    3) Proceed to dcpromo DC3 out of the domain
    4) Test connectivity if clients to the AD
    5) Add the additional Server options
    6) All of the above can be done during office hours.
    it was my understanding (perhaps wrongly) that the group policies were not on the individual Domain Controllers but in Sysvol and as such replicated anyway?
    any advice would be very much appreciated.

    > I am being told that our Group policies are different across different
    > Domain Controllers and to my knowledge that's impossible as we have
    > discussed it should be in the replicated Sysvol.
    Ok, that's a common problem. Fix it and you will be fine:
    http//support.microsoft.com/kb/2218556 (for DFS-R Replication of Sysvol)
    http://support.microsoft.com/kb/315457 (for NTFRS replication)
    > I'm a bit lost on the central repository aspect but prior to saying it
    > makes no sense I just wanted to check my understanding, especially with
    > an MVP!
    I agree. Talking of a "central repository" fro group policy doesn't make
    sense, because group policy from the very beginning lives in AD and
    sysvol, which both are kind of "central repository". Seems they don't
    really know what they're talking about :)
    Martin
    Mal ein
    GUTES Buch über GPOs lesen?
    NO THEY ARE NOT EVIL, if you know what you are doing:
    Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))

Maybe you are looking for