Solved

oracle counts and group by version 8i

Posted on 2014-03-03
6
234 Views
Last Modified: 2014-03-04
I have following query which give list of users and group, I would like to put counts on Users and group by "GroupName"

Please let me know how it is possible

select UNIQUE UserName, GroupName from User where UID in 
(select GUID from group_user) 

User1	Group1
User2	Group1
User3	Group2
User4	Group3
User1   Group3
User1   Group3
User2   Group3 

Open in new window

OUTPUT

Group1 2
Group2 1
Group3 3

Open in new window

0
Comment
Question by:CalmSoul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 39901797
Yes it's possible, what have you coded?

HINT: Use the COUNT(*) and GROUP BY functions in your query.
0
 
LVL 5

Author Comment

by:CalmSoul
ID: 39901832
Added count(*) is giving me following error

Lookup Error
ORA-00936: missing expression
0
 
LVL 23

Expert Comment

by:David
ID: 39901941
Post your statement please, otherwise we're missing...
0
Webinar: MongoDB® Index Types

Join Percona’s Senior Technical Services Engineer, Adamo Tonete as he presents “MongoDB Index Types, How, When and Where Should They be Used?” on Wednesday, July 12, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7).

 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 39901944
select GroupName, count(distinct username)
from User
where UID in  (select GUID from group_user)
group by groupname

that should do it
0
 
LVL 23

Expert Comment

by:David
ID: 39901952
hmmm, I was thinking the where subquery and the group by couldn't be used together, but live and learn :)
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 39901995
now that you mention that ... hadn't tested it
but indeed ... it works ... also found out after testing
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question