Solved

oracle counts and group by version 8i

Posted on 2014-03-03
6
230 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
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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 37

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 37

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and theā€¦
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

685 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