Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL*Plus Question

Re: SQL*Plus Question

From: Brian Peasland <oracle_dba_at_nospam.peasland.net>
Date: Thu, 8 Jun 2006 13:42:48 GMT
Message-ID: <J0JnFK.8vs@igsrsparc2.er.usgs.gov>


Ed_Zep wrote:
> This should be easy but...
>
> I'm trying to get a list from v$session of users logged in more than
> once with the same username but on different machines.
>
> I can do:
>
> select logon_time, username, osuser, machine, count(1) from v$session
> group by logon_time,username, osuser, machine
> having count(1) > 1
>
> but this will only give me one line per user. I need to see the same
> username, etc for say "JSMITH" 3 times if he's logged in three times on
> different machines...
>
> I'd like to exclude rows where the user is logged on twice on the same
> machine.
>
> Many thanks,
>
> Ed.
>

The first thing to do is to get just one line for each time a user is logged in from a particular workstation:

SELECT DISTINCT username,machine FROM v$session;

Now you can use that query above as an inline view to pull those users who are logged in on more than one workstation:

SELECT x.username, COUNT(*) AS num_workstations FROM (SELECT DISTINCT username,machine FROM v$session) x GROUP BY x.username;

HTH,
Brian

-- 
===================================================================

Brian Peasland
oracle_dba_at_nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown
Received on Thu Jun 08 2006 - 08:42:48 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US