Goup by in oracle vs group function in coldfusion

Hello
what is the difference between goup by in oracle vs group
function in coldfusion?

It's easier to list the similarities:
Both use the word "group".
Other than that: they're different things.
Both are well documented in their respective documentation
sources (which
are avaialble online). Suggest you read up.
Adam

Similar Messages

  • Group function in coldfusion

    Hello does anyone know how to use the group function in
    coldfusion
    my tables that out-puts to a html
    is outputing multiple CEENO
    for example CEENO
    11111
    11111
    11111
    11111
    someone here said to use the group function in coldfusion
    do you know where i can put it?
    <table border="2" cellpadding="2" cellspacing="0">
    <tr>
    <th>Record Number</th>
    <TH>PEA_id</TH>
    <th width="120">CEENO</th>
    <TH>Address</TH>
    <TH>ZipCode</TH>
    <th>AdvisoryDate</th>
    </tr>
    <cfloop query="getthecases">
    <tr bgcolor="<cfif currentrow mod
    2>GHOSTWHITE<cfelse>WHITE</cfif>">
    <td>#CurrentRow#</td>
    <td>#PEA_id</td>
    <Td>#CEENO#</td>
    <td>#ST_NO# #ST_initial# #st_dir#</td>
    <td>#ZipCode#</td>
    <td>#dateformat(ADVISORY_DATE,"mm/dd/yyyy")#</td>
    </tr>
    </cfloop>
    </table>

    What they are referencing is the group attribute of the
    CFOUTPUT tag:
    <cfoutput query="qryName" group="groupName">
    #dbgroupvar#
    <cfoutput>
    #otherdbdata#
    </cfoutput>
    </cfoutput>
    However, you have to write the correct SQL to get this to
    work and that includes using the ORDER BY clause in your SQL
    Statement to specify what column on which to group the output.
    For example, the following query would get all employees from
    the database and order them by the department for which they work:
    <cfquery name="qTest" datasource="dsn">
    SELECT name, title, department
    FROM employee
    ORDER BY department
    </cfquery>
    We can use the group attribute of cfoutput to show all
    employees for each department:
    <cfoutput query="qTest" group="department">
    <h1>#department#</h1>
    <table>
    <cfoutput>
    <tr>
    <td>#name#</td>
    <td>#title#</td>
    </tr>
    </cfoutput>
    </table>
    Hope this helps.
    Cheers,
    Craig

  • Grouping error in Oracle's analytic function  PERCENTILE_CONT()

    Hi,
    I have a question regarding the usage of Oracle's analytic function PERCENTILE_CONT(). The underlying time data in the table is of hourly granularity and I want to fetch average, peak values for the day along with 80th percentile for that day. For the sake of clarification I am only posting relevant portion of the query.
    Any idea how to rewrite the query and achieve the same objective?
    SELECT   TRUNC (sdd.ts) AS ts,
             max(sdd.maxvalue) AS max_value, avg(sdd.avgvalue) AS avg_value,
             PERCENTILE_CONT(0.80) WITHIN GROUP (ORDER BY  sdd.avgvalue ASC) OVER (PARTITION BY pm.sysid,trunc(sdd.ts)) as Percentile_Cont_AVG
    FROM     XYZ
    WHERE
              XYZ
    GROUP BY  TRUNC (sdd.ts)  
    ORDER BY  TRUNC (sdd.ts)
    Oracle Error:
    ERROR at line 5:
    ORA-00979: not a GROUP BY expression

    You probably mixed up the aggregate and analytical versin of PERCENTILE_CONT.
    The below should work, but i dont know if it produces the desireed results.
    SELECT   TRUNC (sdd.ts) AS ts,
             max(sdd.maxvalue) AS max_value, avg(sdd.avgvalue) AS avg_value,
             PERCENTILE_CONT(0.80) WITHIN GROUP (ORDER BY  sdd.avgvalue ASC)  as Percentile_Cont_AVG
    FROM     XYZ
    sorry, what is this where clause for??
    WHERE
              XYZ
    GROUP BY  TRUNC (sdd.ts)  
    ORDER BY  TRUNC (sdd.ts) Edited by: chris227 on 26.03.2013 05:45

  • Error while using group function

    Oracle forms6i
    Hai
    While i am compile my coding it compile successfully, but when i tried to executes i shows error in group function
    my coding is
    if (cnt<>0 ) then
    select BARCODE,INTIME,OUTTIME into today_bar,today_in,today_out from dail_att where BARCODE= :Barcode
    and ATTEND_DATE = :bardate;
    update dail_att set outtime = max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate;
    else
    if (cnt2<>0 ) then
    select INTIME,OUTTIME into yest_in,yest_out from dail_att where BARCODE= :Barcode
    and ATTEND_DATE = :bardate-1;
    if(yest_in is not null and yest_out is null) then
    update dail_att set outtime =max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate-1;
    else
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,min(:bartime),:bardate);
    end if;
    else
    if :bartime between 0100 and 0630 then
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,min(:bartime),:bardate-1);
    update dail_att set outtime = max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate-1;
    else
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,:min(bartime),:bardate);
    end if;     
    end if;
    end if;
    while i am trying to this groupfunction it throws error while i use having tell me how to use group function and where
    to use
    Regadrs
    Srikkanth.M

    Hai sir
    I had a table that contain fields
    EMPCODE NUMBER
    EMPNAME VARCHAR2(25)
    BARCODE VARCHAR2(25)
    INTIME VARCHAR2(25)
    OUTTIME VARCHAR2(25)
    INTRTIMEIN VARCHAR2(25)
    INTROUTTIME VARCHAR2(25)
    PERTIMEIN VARCHAR2(25);
    PERTIMEOUT VARCHAR2(25);
    ATTEND_DATE DATE ;
    Consider that a table with 6 fields ie timein,intrtimein,pertimein,pertimeout,intrtimeout,timeout
    I have generating a attendance table and a table contain 6 various times for an employees and we need to arrange it in order
    0815,0816,1230,1250,1645,1646
    If 0815 is the starting time then timein ie mintime
    0816 stored to be in intrtime
    then1250 then it stored in pertimein
    then 1230 then it stored in pertimeout
    then 1645 stored in intrtimeout
    then 1646 stored in timeout
    I tried with max and min function but its not working properly pls tell me some solutions
    Thanks & Regards
    Srikkanth.M

  • PL/SQL equivalent of T-SQL - "group function is not allowed here"

    Hi all, hope someone can give me a hand as I'm pretty stuck! I have been trying to convert some MS SQL Server T-SQL statements into Oracle PL/SQL and am stuck on the below one:
    SELECT
    CA.AssessmentID,
    (SELECT ProductName + ISNULL(' - ' + PrincipalBenefit,'')
    FROM rptPolicySnapshot WHERE PolicyID = MAX(CA.PolicyID)
    AND SnapshotID = 1),
    MAX(CA.PolicyID)
    FROM rptClaimInvoiceLineSnapshot CIL
    INNER JOIN rptClaimAssessmentSnapshot CA
    ON CIL.AssessmentID = CA.AssessmentID
    AND CIL.SnapshotID = CA.SnapshotID
    WHERE CIL.SnapshotID = 1
    GROUP BY CA.AssessmentID
    This works fine in MSSQL but returns the below error in Oracle:
    'ORA-00934: group function is not allowed here'
    If I take out the subquery the query works fine.
    Any ideas as to the syntax? I am new to Oracle so not sure as to how I should go about writing this.
    Thanks in advance!
    Leo

    WITH x AS (SELECT   ca.assessmentid,
                        MAX (ca.policyid) policy_id
               FROM rptclaiminvoicelinesnapshot cil
                    INNER JOIN rptclaimassessmentsnapshot ca
                        ON cil.assessmentid = ca.assessmentid
                       AND cil.snapshotid = ca.snapshotid
               WHERE cil.snapshotid = 1
               GROUP BY ca.assessmentid
    SELECT x.assessment_id,
           x.policy_id,
           productname + decode(principalbenefit,null,null,' - ' || principalbenefit ) prodname
    FROM   rptpolicysnapshot, x
    WHERE  policyid = x.policy_id
    AND    snapshotid = 1I think that's in the neighbourhood.

  • How to create a user_defined grouping function?

    I need to create a user_defined function and use it in my sql statement.
    I know the user_defined function can be used anywhere the build-in function can be used.In oracle,there are grouping functions.
    How can I create a user_defined grouping function and I can use it in my sql statement.

    Hi, can you explain exactly what you are trying to achieve:
    SQL> create or replace function my_func return number as
      2  begin
      3    return 5;
      4  end;
      5  /
    Function created.
    SQL> select deptno,my_func(),max(sal)
      2  from emp
      3  group by deptno,my_func()
      4  /
        DEPTNO  MY_FUNC()   MAX(SAL)
            10          5       5000
            20          5       3000
            30          5       2850

  • ORA-00978  without group function

    I've experienced a strange problem with oracle 11g.
    I've retrieved the oracle exception ORA-00978 even if there was no group function in my query.
    I supposed was a problem in the optimizer so I rebuild the tables statistics, after that the query was execute successfully.
    Does anyone has an idea what the problem is?
    Is possible that a bug exists in the 11g optimizer?
    My oracle version is:
    Oracle Database 11g Enterprise Edition 11.1.0.6.0 64bit Production
    the query i tried is:
    SELECT *
    FROM TBCALENDAR Cal,
    VWCALENDARACTIVITY CA,
    VWSE R,
    TBSCHEDULERPARTITION P,
    TBREGION REG,
    TBRESOURCE RES ,
    TBZIPCITY z
    WHERE Res.id=Cal.RESOURCE_ID
    AND R.RESOURCE_ID=RES.ID
    AND Cal.ACTIVITY_ID=CA.ID
    AND CA.SCHEDULING=1
    AND Cal.SCHEDPARTITION_ID IN
    (select item.PARTITION_ID
    from tbidcprofile prof,
    tbidcpartitem part,
    tbschedpartitem item
    where prof.USERPROFILE_ID=4
    and prof.IDCPARTITION_ID=part.PARTITION_ID
    and part.BUSINESSUNIT_ID=item.BUSINESSUNIT_ID
    and part.REGION_ID=item.REGION_ID )
    AND TRUNC(Cal.START_DT)=trunc(sysdate)
    AND P.ID=Cal.SCHEDPARTITION_ID
    AND REG.ID(+)=Cal.WORKREGION_ID
    AND Z.GEOLOCATION_ID(+)=Cal.HOMEGEOLOC_ID;
    VWCALENDARACTIVITY and VWSE are two views, but I can select from them without any problem.
    I've also tried to remove one view at a time an the error occurs only when the query uses both view at the same time.
    Thanks
    Renzo

    user479513 wrote:
    VWCALENDARACTIVITY and VWSE are two views, but I can select from them without any problem.
    I've also tried to remove one view at a time an the error occurs only when the query uses both view at the same time.
    What are the views definition ?
    Nicolas.

  • How to create a grouping function

    How to create a grouping function ?? For example, can I create a function:myavg and I can use it like :
    select col_a, col_b, myavg(col_c)
    from table_a
    group by col_a, col_b
    Thanks in advance !!
    null

    I don't think that you can create a grouping function in Oracle, but you can create a function and use it in Select statments.
    null

  • Grouping Function usage in SQL

    All,
    How does grouping function work, does it also depends on the sequence of columns used in group by rollup
      select deptno,job, group_id(), sum(sal), grouping(deptno) , grouping(job)
      from emp
      group by rollup (deptno, job) 
      If the query is run by "rollup(job,deptno)" grouping (deptno) returns 1 where as if "rollup(deptno,job)" grouping (deptno) returns 0.
    Does the column sequence in group by rollup decides the returning of grouping(deptno) function. I feel to have some misunderstanding of the way its said in ORACLE documentation. We referred to the below link for our understanding.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions071.htm
    Request the PRO's to discuss and clarify on this.

    Hi,
    ramarun wrote:
    All,
    How does grouping function work, GROUPING (x) returns 1 if the current row represents a superaggregate of x, and 0 otherwise. In other words, if GROUPING (x) is 0, then the row represents a single value of x. If GROUPING (x) is 1, then the row represents a total of all values of x.
    For example the query you posted may produce results like this:
    `   DEPTNO JOB       GROUP_ID()   SUM(SAL) GROUPING(DEPTNO) GROUPING(JOB)
            20 ANALYST            0       6000                0             0
               ANALYST            0       6000                1             0
            10 CLERK              0       1300                0             0
            20 CLERK              0       1900                0             0
            30 CLERK              0        950                0             0
               CLERK              0       4150                1             0
            10 MANAGER            0       2450                0             0
            20 MANAGER            0       2975                0             0
            30 MANAGER            0       2850                0             0
               MANAGER            0       8275                1             0
            10 PRESIDENT          0       5000                0             0
               PRESIDENT          0       5000                1             0
            30 SALESMAN           0       5600                0             0
               SALESMAN           0       5600                1             0
                                  0      29025                1             1Look at the last three rows. On this row
    `   DEPTNO JOB       GROUP_ID()   SUM(SAL) GROUPING(DEPTNO) GROUPING(JOB)
            30 SALESMAN           0       5600                0             0GROUPING (deptno) is 0; so the row represents only deptno=30.
    GROUPINT (job) is 0, so the row represents only job='SALESMAN'.
    SUM (sal) is 5600, so the total salary of all salesmen in department 30 is 5600.
    Now look at this row:
    `   DEPTNO JOB       GROUP_ID()   SUM(SAL) GROUPING(DEPTNO) GROUPING(JOB)
               SALESMAN           0       5600                1             0GROUPING (deptno) is 1; so the row does not represent any one deptno; it is a superaggregate of all deptnos. Notice that the deptno column is NULL, even though there are no rows in the table where deptno is NULL.
    GROUPING (job) is 0, so the row represents only job='SALESMAN'.
    SUM (sal) is 5600, so the total salary of all salesmen in any department is 5600. (As it happens, all the salesmen are in department 30, so this sum is the same as on the previous row.)
    Now look at the last row:
    `   DEPTNO JOB       GROUP_ID()   SUM(SAL) GROUPING(DEPTNO) GROUPING(JOB)
                                  0      29025                1             1GROUPING (deptno) is 1; so the row does not represent any one deptno; it is a superaggregate of all deptnos. Notic that both deptno and job are both NULL on this row of output, even though neither column is ever NULL in the table.
    GROUPING (job) is 0, so the row represents only job='SALESMAN'.
    SUM (sal) is 5600, so the total salary of people with any job and any department is 29025.
    does it also depends on the sequence of columns used in group by rollup Excellent question! Try it an see. Change the order or columns in the GROUP BY clause and see. If you get different results, then the order does matter.
    select deptno,job, group_id(), sum(sal), grouping(deptno) , grouping(job)
    from emp
    group by rollup (deptno, job)  If the query is run by "rollup(job,deptno)" grouping (deptno) returns 1 where as if "rollup(deptno,job)" grouping (deptno) returns 0. You get different results; therefore the order does matter.
    Does the column sequence in group by rollup decides the returning of grouping(deptno) function...Yes.
    "GROUP BY ROLLUP (deptno, job)" means a superaggregate row for each value of job, representing all deptnos, will be formed. That is, you will get one row representing all analysts; another row representing all clerks, another row representing all managers, and so on. This will be similar to the results that you would get if you never mentioned the first expression in the ROLLUP list, that is, deptno. You will not get a superaggregate row representing any one deptno, say, 10.
    "GROUP BY ROLLUP (job, deptno)" means a superaggregate row for each value of deptno, representing all jobs, will be formed. That is, you will get one row representing all anlysts; another row representing deprtment 10, another row representing department 20, and so on. This will be similar to the results that you would get if you never mentioned the first expression in the ROLLUP list, that is, job. You will not get a superaggregate row representing any one job, say, 'ANALYST'.

  • ORA-00935:  group function is nested too deeply - SQL Query is correct...

    select s.sname, to_char(sum(t.amount), 'fm$999999.00')
    from transactions t, salespeople s
    where t.sid = s.sid
    group by s.sname, t.year
    having (t.year = 1997) and max(sum(t.amount));
    I'm trying to print sales person name who had the highest total sell in 1997. I do not see where did i go wrong in the above query...Isn't nested group function allowed?!
    What about this?
    select s.sname, to_char(sum(t.amount), 'fm$999999.00') as "TOTAL"
    from transactions t, salespeople s
    where t.sid = s.sid
    group by s.sname, t.year
    having (t.year = 1997) and sum(t.amount) = (select max(amount) from transactions where year = 1997);
    It should return something, but it does not due lack of data in database. I think the above code is correct. I just need to confirm from you...

    select s.sname, (case when sum(t.amount) > sum(t2.amount)
    then sum(t.amount)
    else sum(t2.amount)
    end) "TOTAL"
    from transactions t, salespeople s
    where t.sid = s.sid
    group by s.sname, t.year
    having t.year = 1997
    union
    select s.sname, sum(t2.amount)
    from transactions t2, salespeople s
    where t2.sid = s.sid
    group by s.sname, t2.year
    having t2.year = 1997;
    Your code looks good, but it does not work in Oracle Developer...
    The above should work isn't it? The inner query gets executed then the outer one so the result i get in

  • JDBC 8.1.6.0.1 Bug with grouping function

    Hi,
    I found a bug in the JDBC 8.1.6.0.1 driver, concerning the new grouping functionality of Oracle 8.1.6. Look at the following code fragment:
    String cSelect = "SELECT DACO_VU_NAME AS DIM1, ' ' AS DIM2, TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm') AS DIM_DATE, GROUPING(DACO_VU_NAME) AS DIM1GROUP, GROUPING(' ') AS DIM2GROUP, GROUPING(TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm')) AS DIM_DATEGROUP, sum(DACO_BRUTTOBETRAG_TX) AS VALUE FROM DATENCONTAINER GROUP BY CUBE (DACO_VU_NAME, '-', TO_CHAR(DACO_VERKAUFSDATUM,'yyyymm') ) ORDER BY 1,2,3";
    try {
    System.out.println("SELECT: " + cSelect);
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery(cSelect);
    while (rset.next()) {
    String cTest1 = rset.getString("DIM1");
    String cTest2 = rset.getString("DIM2");
    String cTest3 = rset.getString("DIM_DATE");
    String cChar1 = rset.getString("DIM1GROUP");
    String cChar2 = rset.getString("DIM2GROUP");
    String cChar3 = rset.getString("DIM_DATEGROUP");
    System.out.println(cTest1 + "\t" + cTest2 + "\t" + cTest3 + "\t" + cChar1 + "\t" + cChar2 + "\t" + cChar3);
    }When I compile this with the mentioned JDBC version and run it with java 1.2.2 (JDeveloper 3.1), i get the following output:
    Ahrend GmbH & Co. KG 200003 0 0 0
    Ahrend GmbH & Co. KG 200003 1 0 0
    Ahrend GmbH & Co. KG 200004 0 0 0
    Ahrend GmbH & Co. KG 200004 1 0 0
    Ahrend GmbH & Co. KG null 0 0 1
    Ahrend GmbH & Co. KG null 1 0 1
    null 200003 0 1 0
    null 200003 1 1 0
    null 200004 0 1 0
    null 200004 1 1 0
    null null 0 1 1
    null null 1 1 1As you can see, the grouping columns are mixed up. In this example, everywhere a normal row shows a "null" value, a corresponding grouping row should show a "1", but as you can see, for the last 6 rows, the ones are not in the first, but in the second grouping row.
    When I compile the example with the Oracle 8.1.5 JDBC driver, I get the following, correct, output:
    Ahrend GmbH & Co. KG 200003 0 0 0
    Ahrend GmbH & Co. KG 200004 0 0 0
    Ahrend GmbH & Co. KG null 0 0 1
    Ahrend GmbH & Co. KG 200003 0 1 0
    Ahrend GmbH & Co. KG 200004 0 1 0
    Ahrend GmbH & Co. KG null 0 1 1
    null 200003 1 0 0
    null 200004 1 0 0
    null null 1 0 1
    null 200003 1 1 0
    null 200004 1 1 0
    null null 1 1 1The special thing about this example is, that I use a constant row for grouping (row 2). If you use a normal database row, everything works fine with 8.1.6.0.1, but nevertheless, this should be a bug.
    Any comments on this are highly appreciated, since I need the JDK 1.2 for the application and I didn't find a working Oracle 1.2 JDBC version.
    Thanks,
    Thorsten.

    Patches can be obtained from an Oracle Support Services technical analyst.
    null

  • Grouping function

    Hi,
    Is any difference between grouping function in oracle9i and oracle19g?
    Thanks,
    Michael.

    There is a book that lists all the new features of 10g
    Bye Alessandro
    Message was edited by:
    Alessandro Rossi
    And these too!!
    http://download.oracle.com/docs/cd/B14117_01/server.101/b10750/chapter1.htm#sthref581
    http://download.oracle.com/docs/cd/B14117_01/server.101/b10750/chapter1.htm#sthref629

  • Group function problem

    Hi, I need to list the shortest string along with the number of characters in the string, so far I've come up with:
    SELECT eventtitle, MIN(LENGTH(eventtitle))
    FROM event
    Oracle XE is giving the error "not a single-group group function", but I can't quite see how to get "eventtitle" on it's own, the function "MIN(LENGTH(eventtitle))" does give me the desired result if run by its self. I'm grateful for any assistance!

      1  with t
      2  as
      3  (
      4   select 'abcd' short_string from dual
      5   union all
      6   select 'a' short_string from dual
      7   union all
      8   select 'b' from dual
      9  )
    10  select short_string, rownum rn from t
    11* order by length(short_string)
    SQL> /
    SHOR         RN
    a             2
    b             3
    abcd          1one version using analytics
      1  with t
      2  as
      3  (
      4   select 'abcd' short_string from dual
      5   union all
      6   select 'a' short_string from dual
      7   union all
      8   select 'b' from dual
      9  )
    10  select short_string, len from
    11  (
    12  select short_string, length(short_string) len, min(length(short_string)) over() min_length from t
    13* ) where len = min_length
    SQL>
    SHOR        LEN
    a             1
    b             1Regards
    Raj

  • GROUP BY without GROUP functions

    I red in Oracle university book that you can use the GROUP BY clause without using a group function in the SELECT list, can someone give me an example using the popular table 'employees' OR 'departments'

    I cannot think of why or how such a query would be useful except it you selected the same column you grouped on you would be doing the equilivent of a select distinct:
    UT1 > select deptno from emp group by deptno;
    DEPTNO
    10
    20
    30
    HTH -- Mark D Powell --

  • Group functions

    Hello.
    How can I use user define group function (Oracle 9i feature) in the same report with system define (sum, max).
    I use Discoverer 9i.
    Thanks.

    hi,
    Try this in Fx
    SUM(Absence_Days by person_id)
    Thanks,
    Saichand.v

Maybe you are looking for

  • ITunes - 2 user accounts - How do I combine to get one set of Playlists ...

    I am very new to Mac. I have 2 user accounts set-up (really would rather have only one), and the iTunes is different under each account. I would like to only have one set of iTunes Music library and Playlists. Can anyone help me out?

  • Every time I watch any online video mac mini has kernel panic

    Everytime I have attempted to watch any online video, (World Cup, online seminars, Photoshop tutorials, even a couple of times on youtube) this mac mini just shuts down and forces a restart. If anyone has any suggestions, it would be greatly apprecia

  • Wrong order of sql queries

    Hello, I have an application working properly except for one thing. The commands I do are in order: 1. Register first employee (new object) 2. Register second employee (new object) 3. Register company (new object) 4. Associate employees with company

  • Problem with packages and findClass()

    Im trying to make a loader for java project it runs fine from a batch file with this inside it. @echo off java -classpath rscdaemon.jar;lib/xpp3.jar;lib/xstream.jar;lib/hex-string.jar com.rscd.client.mudclient rscdaemon.org pause {code} now when I tr

  • Using analytic function in a view

    Hello to all Sorry If I use this thread sql not merge using analytic functions for my question, From example you write and from Tom explain is not possible create a view on analytic function? Thanks and sorry again