More than 1 column in the group by clause

DB Version:10gR2
I understand the basics of GROUP BY clause. I have a question on why we have on more than 1 columns in GROUP BY clause.
In the below example, the course name by itself does not make up a group. A Course name plus its BeginDate make up a group. This is the whole point of having more than 1 columns in the GROUP by clause. Right?
SQL> select r.course, r.begindate , count(r.attendee) as attendees
  3   from registrations r
  4   group by r.course, r.begindate
  5   order by course
  6  /
COURSE BEGINDATE      ATTENDEES
JAVA    12/13/1999           5
JAVA    2/1/2000             3
OAU     8/10/1999            3
OAU     9/27/2000            1
PLS     9/11/2000            3
SQL     4/12/1999            4
SQL     10/4/1999            3
SQL     12/13/1999           2
XML     2/3/2000             2

ExpansiveMind wrote:
Thanks Dmorgan. I am just learning the basics of GROUP BY clause. I have noticed that all Non-aggregate columns in SELECT list have to be present in the GROUP BY clause. I thought it was a "syntactical requirement". Now, i realise that these columns are present in the GROUP BY clause because only a combination of columns make up a group.Well, it is a bit of both actually. It is a syntactic requirement that all non-aggregated columns in the select list must appear in the group by clause. However, the non-aggregated columns in the select list is what defines your group. Your two examples define two different groups, and would answer two different questions.
John

Similar Messages

  • How to create combobox to display more than one columns

    I need kind help with the following question. As the combobox includes two pieces--textbox and the combobox list. Then how to create a combo box bean, which is based on table EMP(empno number(6), ename varchar2(40)) records for example, to achieve these features:
    1) allow more than one columns to be displayed in its records list--e.g., I need to show these records:
    empno (value) ename (label)
    103 David M Baker
    104 David M Baker
    105 Kelly J Volpe
    106 Krista F Carpenter
    107 Michelle P Silverman
    The two 'David M Baker's are different employees, but unfortunately, with the same name.
    2) allow combo box list to return the column value 'empno' even though it shows both columns as above. i.e., if user picks the second record above, then the combobox list returns 104 to the textbox in the background, but the 'David M Baker' is displayed on the textbox. Of course the combobox list may return 'David M Baker' if needed when there is only one column in the list as the current standard feature.
    3)allow partial match search by typing in some letters. i.e., if user types in the textbox of the combobox letter 'K' or 'k' then the partially matched records
    105 Kelly J Volpe
    106 Krista F Carpenter
    should be automatically displayed in the combobox list, not the whole list as above; then user may double click to choose one of the two or if user continues to type in 'R' or 'r', then the uniquely matched record 'Krista F Carpenter' is displayed in the textbox and the 106 is returned to the textbox.
    4) as a bonus if it's doable, allow combobox to return values to different textboxes when its records list has more than one columns.
    The reason I need these features is that I am working on the project migrated from Microsoft Access applications to centralized Java version web application. We at beginning promised to users community that Java swing will provide all the GUI user friendly features Microsoft Access has, but now we got stucked--we ate our words and got tons of complains from our users community. This is just the most needed component I posted here. I really hope that Java would add all the default GUI user-friendly features to compete with MS since its Win95 GUI has been accepted as industry standard. And most users are used to it. They claimed that they don't know and don't care what tool you use the newly created application should be more user friendly, not the opposite.
    I would be very much appreciated if any one would help me with this item.

    Thanks for your comments. I think nobody expects Sun to write everything including special features for its components. But I do think Sun should provide at least those standard user-friendly features for the GUI components because most users have been used to the GUI user-friendly features provided by Win95 and Access/Excel applications. Then this will help us to productively create applications to beat MS applications.
    Other wise like me, to get the existing GUI features, existed in old MS Access application, for our migrated Java application, I must re-create the GUI components library first which is a big burden to me at least, for others it might be fun for coding on their own from scratch, but I have to focus on the timing of project.
    If you really can pass the request to Sun and push them move a bit, please pass these words: before Sun starts to revise them, please play around window GUI, e.g., Access/Excel applications, then plan what to do, the bottom line is to equally match or better than them in FUNCTIONALITY(Look and feel is not my focus here). Don't ignore the influence of Windows regardless of you hate it or love it, the reality is most users are so familiar with windows GUI features which are accepted as industry standard. Thus the choice is to match or better to beat them. Don't make your car by closing your door, don't assume users will like what you come out in a closed room.

  • Attachment with more than 255 columns

    Hi together,
    i want to send a mail in background with an attachment with more than 255 columns through the function module SO_DOCUMENT_SEND_API1 . The required content-structure of this function module have 255 columns......
    I try it also with the function module SO_DOCUMENT_REPOSITORY_MANAGER with the method 'SEND'
    but i can't suppress the popup of this function module.
    Have anybody an solution for me ?
    br
    Markus
    Edited by: Markus Garyant on Aug 21, 2008 3:39 PM

    Attachement table has a strucutre SOLISTI1 which can contain only 255 characters BUT you can use the CL_ABAP_CHAR_UTILITIES=>CR_LF for the new line  and CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB for the column separater.
    You need to concatenate this Separters in the attachment table.
    Check out this example:
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    Regards,
    Naimesh Patel

  • More than one column retrieved in "report and form" page

    HELLO!
    let's see if anybody can help me with this... i'm sure it's a stupid problem but i really don't know how to solve it.
    when i create a new application with APEX, i want to add a "report and form" page. i select the table where de data is, and then click on add page. then i go to the page definition for the form that just has been created but there's no option for selecting more than one column as the link column...
    i mean, i want to show a report with all the columns from the table and then, by selecting one of them, the form should display that column but the problem is that the primary key of the table is formed by 6 columns and i always receive the "more than one column retrieved" message as it's trying to retrieve the information using only one column. is there any way to make the link column be composed by 6 or 7 columns??

    APEX can handle 2 primary key for one table (if you are using the automated fetch row and the automated process row).
    In your case, you'll have to create your own "fetch process (page rendering)" and "DML process (page processing)".
    Flex
    Homepage : http://www.insum.ca
    InSum Solutions' blog : http://insum-apex.blogspot.com

  • Display more than 7 users in the #SAPB1 calendar

    How do I see more than 7 users in the #SAPB1 calendar? Transpose the present layout - users vertical/time line horizontal would also be a good idea. I'm aware that you can change the 7 by using the formsettings but this is too time consuming.

    Hi Martin,
    Only way to show more users is enable them from form settings.
    also You cannot display more than seven users in the Group View simultaneously.
    Thanks,
    neetu
    Edited by: Neetu Dhami on Dec 20, 2011 5:01 PM

  • View more than 10 columns with ZANALYSIS_PATTERN

    Hello friends. I changed the adoc template by a ZANALYSIS_PATTERN which leave with 15 columns but portal shows me just up to 10 columns. Any help is well come.
    Regards.
    Christian.

    I have already done so. For example when I put 5 columns in the RSCUSTV27 portal correctly displays me the 5 columns. The problem occurs when I put more than 10 columns in the RSCUSTV27, the only portal shows me up to 10 columns, can't more than 10 columns appear me in the portal.

  • Group by on more than 2 columns in SharePoint List

    Hi,
    Is there any way to use Group-by on more than 2 columns? I know there is a way using SPD which I have implemented as well, however it makes the page READ-ONLY. 
    Any other way? May be using custom code?

    Try this
    http://chanakyajayabalan.wordpress.com/2010/03/15/group-by-for-more-than-two-columns-in-sharepoint-list/
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/05fbde73-efdb-40dc-a206-55d56caa21d4/make-group-by-for-3-or-more-then-3-columns-in-sharepoint-2010-list?forum=sharepointdevelopmentprevious
    http://techtrainingnotes.blogspot.in/2011/01/sharepoint-group-by-on-more-than-2.html

  • How to ORDER BY Different column than in the group by clause.

    Hello, I have this sql statement
    SELECT COUNT([Tags]) AS CNT, [Tags]
    FROM [Tags], [Images]
    WHERE
    ([Images].[Tags] LIKE '%' + [Tags].[LongTag] + '%') AND
    ([Tags].AllowTagPost = 'True' )
    GROUP BY [Images].[Tags]
    HAVING COUNT([Tags]) > 30
    ORDER BY [Tags].[LastTagPost] DESC
    It returns the tags, the number of occurances sorted by count.  However, I want to sort it by a column in the Tags table named LastTagPost (DATETIME)  The idea is to get the tag that hasn't been used in the longest time and also has more occurances
    than 30 in the image table.  When I try to order by this column i get an error that i'm sure most of you are all to familer with.
    Error:
    Column "Tags.LastTagPost" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
    Any help would be greatly appreciated.

    Couldn't you just include the LastTagPost as a MIN?
    DECLARE @tags TABLE (LastTagPost DATETIME, LongTag VARCHAR(100), allowTagPost CHAR(5))
    DECLARE @images TABLE (tags VARCHAR(10))
    SELECT COUNT(i.Tags) AS CNT, i.Tags, MIN(t.LastTagPost) AS lastTagPost
    FROM @Tags t
    INNER JOIN @Images i
    ON i.Tags LIKE '%' + t.LongTag + '%'
    WHERE t.AllowTagPost = 'True'
    GROUP BY i.Tags
    HAVING COUNT(i.Tags) > 30
    ORDER BY LastTagPost DESC
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • How to create SharePoint: Group By on more than 2 columns in a view (SP 2013)

    Hi All,
    I want to create Group by column on more than 2 columns in a view in SharePoint 213 list.
    The group It for CurrentUser,Yearly,Monthly andWeekly.
    How can I achieve It?
    Thanks in Advance

    Hi,
    According to your post, my understanding is that you want to group by on more than 2 columns in a view.
    You can use Data View Web Part in SharePoint Designer and add some changes & additions.
    For more information, you can refer to:
    Group by for more than two columns in SharePoint list
    SharePoint: Group By on more than 2 columns in a view (SP 2010)
    SharePoint 2013 – Add DataView WebPart with SharePoint Designer 2013
    Hack: Data View Web Parts in SharePoint 2013
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Simple request... More than one column to organize tracks?!

    Is it possible to organize tracks with more than one column, such as 'name' followed by 'comment', for example.. The way I have it now, each time you click on a new header, the last header cannot be used in combination, i.e. only the currently selected header can be used. Thanks!

    strangelittleman,
    I don't know of any way to do this, but I agree it would highly useful. (Like the sorting algorithms in word processors that let you sort by column 2 followed by column 6, etc., or whatever.)
    Here is a work-around. If the column you use to arrange your songs, say song name, produces a fairly sizable listing for the same song (Louie Louie, for instance) and you want to organize that by artist name (to group the multiple versions done by Motorhead or IGGY POP, for instance), then just select the songs of a given name and copy them to a new playlist. Then select the artist name column to organize by that.
    This is clumsy, and only useful if you have a large number of songs in the first sorting category (song name in the example above) and duplicates that you wish to detect in the second sorting category (artist name in the example above). But in some cases it may be helpful.
    Drake

  • SUM over more than 1 column

    Hi,
    I want to summate the values in more than 1 column. My code is like this
    SELECT SUM(Column_A + Column_B) AS Column_C FROM TABLE GROUP BY ID
    but this doesn't work.
    I also tried
    SELECT SUM(Column_A & Column_B) AS Column_C FROM TABLE
    doesn't worked either ...
    Any ideas?
    Greetings from Germany
    Lars

    You may have NULL values in those columns:
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> with t as (
      2    select 100 id, 1 a,  10 b  from dual union all
      3    select 100,    2,    20    from dual union all
      4    select 100,    3,    null  from dual union all
      5    select 100,    null, 40    from dual union all
      6    select 100,    null, null  from dual)
      7  --
      8  SELECT SUM(a + b) AS c
      9    FROM t
    10   GROUP BY ID;
             C
            33
    1 row selected.
    test@ORA10G>You probably want to see 76 here. So -
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> with t as (
      2    select 100 id, 1 a,  10 b  from dual union all
      3    select 100,    2,    20    from dual union all
      4    select 100,    3,    null  from dual union all
      5    select 100,    null, 40    from dual union all
      6    select 100,    null, null  from dual)
      7  --
      8  SELECT SUM(NVL(a,0) + NVL(b,0)) AS c
      9    FROM t
    10   GROUP BY ID;
             C
            76
    1 row selected.
    test@ORA10G>
    test@ORA10G>If you simply get a NULL, I'll bet you have NULLs for all records in both those columns.
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> with t as (
      2    select 100 id, null a,  null b  from dual union all
      3    select 100,    null,    null    from dual union all
      4    select 100,    null,    null  from dual union all
      5    select 100,    null, null    from dual union all
      6    select 100,    null, null  from dual)
      7  --
      8  SELECT SUM(a + b) AS c
      9    FROM t
    10   GROUP BY ID;
             C
    1 row selected.
    test@ORA10G>Use NVL. Make life easy.
    isotope

  • Colorization of more than 500 columns in CFBuilder

    Hi,
    For those who faced issues and reproted bugs related to colorization not working for more than 500 columns, please refer to the blog post here:
    http://blogs.adobe.com/cfbuilder/2009/07/colorization_of_more_than_500.html
    Thanks,
    Dipanwita
    http://blogs.adobe.com/cfbuilder

    @John Is your response for Open Directory users because I can say with certainty that your response is not true for AD searches.  The filter box only whittles down the intial 500 displayed results (appears to from my testing).  I can view all 8000 of my groups (yes I tweaked the 1000 cap for LDAP queries on the ad server) and up to 8000 users in Directory Utility, even do individual searches for undisplayed users (actually have 50000 or so) and still get them back.  It seems Directory Utilitity DOES form LDAP queries correctly and efficiently, whereas Server app does not.  It seems Server app, at least against an AD server, tries to LDAP query for everything, and only filters down the max results it gets back.  Am I wrong?  If I were, I should be able to use the search box and still get the same 8000 groups I do in Directory Utility, which I don't.  Know how to fix?
    To clarify: This only happens when I need to give access permissions to "Services" in the Users or Groups section under Accounts.  Intestingly, looking up the users and groups to set permissions for the actual Sharepoint, works just fine.
    @Antonio While you're right it doesn't seem Server App can come anywhere close to Active Directory in terms of managing the entire infrastructure, I think you're wrong when you sort of insinuate that it shouldn't be able to work in tandem with it.  Forming the LDAP queries to AD better seems like such a simple thing to fix - nobody is asking it do the same workload as AD.  I work at an educational institution that is AD infrastructure on the whole, but I just happen to manage an Arts college that it's part of and I prefer the Server App + Deploy Studio + Remote Desktop to manage our 90% rate of macs, as opposed to using the SCCM and AD tools I easily could use.  And I doubt I'm the only mac admin in a similar situation.  This is something Apple could and SHOULD easily fix.

  • Custom Breaking of more than three columns - apex 3.0

    Trying to create an application that has more than 3 columns for break formatting - have read of a technique thats quite long winded using decodes and grouping sets etc - but seems a bit complex for such a (supposedly) simple query.
    Just wondering if anyone else has come across an easy way to do this - including potentially modifying the template etc to allow more than the default values for breaking options?
    Thanks!
    Sam

    Hi,
    Excellent example in this thread of how to achieve what you want using the LAG Function: -
    Re: PL/SQL code for handling more than 3 levels of breaks.
    Cheers,
    Mike

  • How to display more than 60 columns in a report

    I have a table defined as follows
    id
    column_name
    column_value
    data sample
    id col_name column_value
    1 col1 val1
    1 col2 val2
    1 col3 val3
    2 col1 val1
    2 col2 val2
    2 col3 val3
    now I want to display the data in a report as follows
    id col1 col2 col3
    1 val1 val2 val3
    2 val1 val2 val3
    I was able to generate output using pivots [http://technology.amis.nl/blog/1197/pivot-dynamic-data]
    the problem is that I can have more that 60 columns retrieved in each row, the pivot solution will retrieve them correctly but I can't display more than 60 columns in apex reports, why this restriction in apex, any solution

    Hello:
    In the Source section of the report definition choose 'Use Generic Column Names (parse query at runtime only)' and then specify a suitable value for 'Maximum number of generic report columns:'
    Varad

  • How can I put more than One ComboBox in the Driving Frame of a Frame Driver

    Hi,
    I am working with a Frame Driver and I want that in the Driving Frame put more than one ComboBox to filter the report, for example, I want to put one combobox for City, another for Year, and another for Month, and when the user select the City, Year and Month and do click in Submit button, then in the Target Frame appears the information for those filters.
    Does anybody know how to do that?
    Thanks a lot.
    Bye,

    Hi,
    It is not possible to have more than one combo in the source frame. This is because frame drivers can take only
    two columns in the sql query, one is the display value and the other the return value.
    Thanks,
    Sharmila

Maybe you are looking for

  • There should be a new System Update like good old Software Installer

    I believe that there was once a program called Software Installer that was replaced by System Update. I liked the old one because of its clear layout and information: There was a column with software installed, column with current version and column

  • Connecting MBA to HDTV

    This is going to be my first time connecting my Macbook Air to a TV. I would like to know what I need in order to do that and get the best display quality. I already have an HDMI cable that I bought a long time ago and that is connected in a PS3. Do

  • Lightroom 2.1 Crashing Finder

    I've installed Lightroom 2.1 on my Leopard 10.5.5 Mac Pro. Now, whenever I start lightroom, my disk Volumes disappear from my desktop and I cannot make the Finder my active app. I can't right click on my desktop, or open a new finder window, or anyth

  • Report Viewer fails in IE11

    I installed IE 11 yesterday and now all my SSRS reports do not display in the viewer.  We are using url to access reports on our report server and when the report tries to open it sits on the spinning wheel and never displays.  It worked perfect unde

  • Floating Footer in Safari

    Hi there made website www.huntfilms.ie but the footer is floating in safari ; that is it is not sticking to the bottom of the page anyone any ideas regards Barry code below <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3