Solved

oracle counts and group by version 8i

Posted on 2014-03-03
6
223 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
Comment Utility
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
Comment Utility
Added count(*) is giving me following error

Lookup Error
ORA-00936: missing expression
0
 
LVL 23

Expert Comment

by:David
Comment Utility
Post your statement please, otherwise we're missing...
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 36

Accepted Solution

by:
Geert Gruwez earned 500 total points
Comment Utility
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
Comment Utility
hmmm, I was thinking the where subquery and the group by couldn't be used together, but live and learn :)
0
 
LVL 36

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Via a live example, show how to take different types of Oracle backups using RMAN.

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now