Solved

oracle counts and group by version 8i

Posted on 2014-03-03
6
225 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange msg in the SSMS pane 13 48
Queries 15 34
su - oracle could not open session 6 50
Extract string portion 2 13
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to take different types of Oracle backups using RMAN.

910 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

23 Experts available now in Live!

Get 1:1 Help Now