SQL or Powershell query to get the SCOM management group id for SCOM 2007 R2 & 2012 / 2012 R2

Hi All,
Can any one provide me the SQL or Powershell query to get the SCOM management group id for SCOM 2007 R2 & 2012 / 2012 R2
I had a SQL query which will query the data from data warehouse and give the management group id but i have lost it for all 3 above.
Gautam.75801

Hi Gautam,
Hope it helps:
http://blog.tyang.org/2013/03/13/data-aggregation-field-became-empty-in-opsmgr-2007-linked-performance-report/
http://blog.tyang.org/2012/09/05/mp-authoring-targeting-rms-or-ms/
Natalya
### If my post helped you, please take a moment to Vote as Helpful and\or Mark as an Answer

Similar Messages

  • Powershell script: to get the AD Security Group Name

    I need PowerShell script that takes input: AD Security Group Name and loop
    through all web applications and their content in the farm to know where this particular group is used.

    hi
    AD groups are represented in Sharepoint as SPUser object with
    SPUser.IsDomainGroup set to true. I.e. you may use the same script which is used for users:
    Powershell script to find permissions for a specific user.
    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

  • SQL query to get the Datetime 06 hours prior to the table Datetime value

    Hi Experts,
                    I'm just trying to create a SQL query to get the Datetime which should be 06 hours prior to my Table column value(Executiontime),
    Eg: my Executiontime(column) value is 07:00AM means, this query should fetch the detail of first VMName from table at 01:00AM, 
    SQL Table Name: TestTable
    Columns: VMName(varchar),status(varchar) Executiontime(Datetime)
    SQL Query : Select Top 1 VMName from
    TestTable where convert(date,Exeutiontime)=convert(date,getdate()) and
    status='0' and ExecutionTime > dateadd(hour,6,getdate())
    Request someone to alter this Query to my requirement or give me the new one.
    Regards,
    Sundar
    Sundar

    Hi All,
            Thanks for your Prompt response. I tried the below queries, but still I don't have any luck. Actually the queries are returning the value before the condition met (say when the time difference is more than 06 hours). I want the
    query to return exactly @ 06 hour difference or less than 06 hours,
    Query 01: Select Top 1 VMName from TestTable where
    convert(date,Exeutiontime)=convert(date,getdate())
    and status='0'
    and ExecutionTime >
    dateadd(hour,-6,getdate())
    Query 02: Select
    Top 1 VMName from TestTable where
    status='0'
    and ExecutionTime >
    dateadd(hour,-6,getdate())
    Query 03: Select
    Top 1 VMName from TestTable where status='0'
    and ExecutionTime >
    dateadd(hour,-6,ExecutionTime)
              Can someone point out the mistake please.
    Regards,
    Sundar
    Sundar

  • SQL query to get the list of approvals

    Hi,
    Could someone let me know the SQL query to get the list of all the pending approvals for a user in OIM 11g R2.
    Thanks

    There are a few ways to do this:
    -  The easiest would be to use a Relationship Query from the CMC. To do this, go to the Universes section on the CMC, right click on the relevant universe, select tools >> Check Relationships.
    - Use Query Builder. You will need more than one query to pull the information you need. You could try something like the below (for Webi)
    SELECT SI_NAME, SI_WEBI, SI_DATACONNECTION FROM CI_APPOBJECTS
    WHERE SI_KIND = 'universe' and SI_NAME = 'Universe Name'
    This will give you a list of Webi Reports by SI_ID.
    You'll need another query to list Webi report names:
    SELECT SI_NAME FROM CI_INFOOBJECTS WHERE SI_ID IN (SI_ID from query above)
    - This is trivial via Auditing / the Activity universe. This of course will only return reports that have already run.
    Best.
    Srinivas

  • Powershell script to get the low disk space on the servers...

    Hi,
    We have many SQL & Sharepoint servers running on windows server. I need some Powershell script to get the low disk space on those servers and it should send an mail alert saying "Disc d:\ have less than threshold 15% free space".
    Awaiting for response.
    Thanks
    Anil

    you should be able to use this powershell script which you can run as a scheduled task.
    just change the details at the start of the script to point the script to the right location to create log files. you will need to have a plain text file containing a list of server names or ip addresses that you want to check drive space on.
    # Change the following variables based on your environment
    #specify the path to the file you want to generate containing drive space information
    $html_file_dir = "\\server\share\DriveSpace"
    #specify the path and file name of the text file containing the list of servers names you want to check drive space on - each server name on a seperate line in plain text file
    $server_file = "\\server\share\servers.txt"
    #speicfy the from address for the email
    $from_address = "[email protected]"
    #specify the to address for the email
    $to_address = "[email protected]"
    #specify the smtp server to use to send the email
    $email_gateway = "smtp.domain.com" # Can either be DNS name or IP address to SMTP server
    # The seventh line from the bottom (line 167) is used if your smtp gateway requires authentication. If you require smtp authentication
    # you must uncomment it and set the following variables.
    $smtp_user = ""
    $smtp_pass = ""
    # Change the following variables for the style of the report.
    $background_color = "rgb(140,166,193)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
    $server_name_font = "Arial"
    $server_name_font_size = "20px"
    $server_name_bg_color = "rgb(77,108,145)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
    $heading_font = "Arial"
    $heading_font_size = "14px"
    $heading_name_bg_color = "rgb(95,130,169)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
    $data_font = "Arial"
    $data_font_size = "11px"
    # Colors for space
    $very_low_space = "rgb(255,0,0)" # very low space equals anything in the MB
    $low_space = "rgb(251,251,0)" # low space is less then or equal to 10 GB
    $medium_space = "rgb(249,124,0)" # medium space is less then or equal to 100 GB
    #### NO CHANGES SHOULD BE MADE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
    # Define some variables
    $ErrorActionPreference = "SilentlyContinue"
    $date = Get-Date -UFormat "%Y%m%d"
    $html_file = New-Item -ItemType File -Path "$html_file_dir\DiskSpace_$date.html" -Force
    # Create the file
    $html_file
    # Function to be used to convert bytes to MB or GB or TB
    Function ConvertBytes {
    param($size)
    If ($size -lt 1MB) {
    $drive_size = $size / 1KB
    $drive_size = [Math]::Round($drive_size, 2)
    [string]$drive_size + ' KB'
    }elseif ($size -lt 1GB){
    $drive_size = $size / 1MB
    $drive_size = [Math]::Round($drive_size, 2)
    [string]$drive_size + ' MB'
    }ElseIf ($size -lt 1TB){
    $drive_size = $size / 1GB
    $drive_size = [Math]::Round($drive_size, 2)
    [string]$drive_size + ' GB'
    }Else{
    $drive_size = $size / 1TB
    $drive_size = [Math]::Round($drive_size, 2)
    [string]$drive_size + ' TB'
    # Create the header and footer contents of the html page for output
    $html_header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Server Drive Space</title>
    <style type="text/css">
    .serverName { text-align:center; font-family:"' + $server_name_font + '"; font-size:' + $server_name_font_size + `
    '; font-weight:bold; background-color: ' + $server_name_bg_color + '; border: 1px solid black; width: 150px; }
    .headings { text-align:center; font-family:"' + $heading_font + '"; font-size:' + $heading_font_size + `
    '; font-weight:bold; background-color: ' + $heading_name_bg_color + '; border: 1px solid black; width: 150px; }
    .data { font-family:"' + $data_font + '"; font-size:' + $data_font_size + '; border: 1px solid black; width: 150px; }
    #dataTable { border: 1px solid black; border-collapse:collapse; }
    body { background-color: ' + $background_color + '; }
    #legend { border: 1px solid black; ; right:500px; top:10px; }
    </style>
    <script language="JavaScript" type="text/javascript">
    <!--
    function zxcWWHS(){
    if (document.all){
    zxcCur=''hand'';
    zxcWH=document.documentElement.clientHeight;
    zxcWW=document.documentElement.clientWidth;
    zxcWS=document.documentElement.scrollTop;
    if (zxcWH==0){
    zxcWS=document.body.scrollTop;
    zxcWH=document.body.clientHeight;
    zxcWW=document.body.clientWidth;
    else if (document.getElementById){
    zxcCur=''pointer'';
    zxcWH=window.innerHeight-15;
    zxcWW=window.innerWidth-15;
    zxcWS=window.pageYOffset;
    zxcWC=Math.round(zxcWW/2);
    return [zxcWW,zxcWH,zxcWS];
    window.onscroll=function(){
    var img=document.getElementById(''legend'');
    if (!document.all){ img.style.position=''fixed''; window.onscroll=null; return; }
    if (!img.pos){ img.pos=img.offsetTop; }
    img.style.top=(zxcWWHS()[2]+img.pos)+''px'';
    //-->
    </script>
    </head>
    <body>'
    $html_footer = '</body>
    </html>'
    # Start to create the reports file
    Add-Content $html_file $html_header
    # Retrieve the contents of the server.txt file, this file should contain either the
    # ip address or the host name of the machine on a single line. Loop through the file
    # and get the drive information.
    Get-Content $server_file |`
    ForEach-Object {
    # Get the hostname of the machine
    $hostname = Get-WmiObject -Impersonation Impersonate -ComputerName $_ -Query "SELECT Name From Win32_ComputerSystem"
    $name = $hostname.Name.ToUpper()
    Add-Content $html_file ('<Table id="dataTable"><tr><td colspan="3" class="serverName">' + $name + '</td></tr>
    <tr><td class="headings">Drive Letter</td><td class="headings">Total Size</td><td class="headings">Free Space</td></tr>')
    # Get the drives of the server
    $drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=3" -ComputerName $_ -Impersonation Impersonate
    # Now that I have all the drives, loop through and add to report
    ForEach ($drive in $drives) {
    $space_color = ""
    $free_space = $drive.FreeSpace
    $total_space = $drive.Size
    $percentage_free = $free_space / $total_space
    $percentage_free = $percentage_free * 100
    If ($percentage_free -le 5) {
    $space_color = $very_low_space
    }elseif ($percentage_free -le 10) {
    $space_color = $low_space
    }elseif ($percentage_free -le 15) {
    $space_color = $medium_space
    Add-Content $html_file ('<tr><td class="data">' + $drive.deviceid + '</td><td class="data">' + (ConvertBytes $drive.size) + `
    '</td><td class="data" bgcolor="' + $space_color + '">' + (ConvertBytes $drive.FreeSpace) + '</td></tr>')
    # Close the table
    Add-Content $html_file ('</table></br><div id="legend">
    <Table><tr><td style="font-size:12px">Less then or equal to 5 % free space</td><td bgcolor="' + $very_low_space + '" width="10px"></td></tr>
    <tr><td style="font-size:12px">Less then or equal to 10 % free space</td><td bgcolor="' + $low_space + '" width="10px"></td></tr>
    <tr><td style="font-size:12px">Less then or equal to 15 % free space</td><td bgcolor="' + $medium_space + '" width="10px"></td></tr>
    </table></div>')
    # End the reports file
    Add-Content $html_file $html_footer
    # Email the file
    $mail = New-Object System.Net.Mail.MailMessage
    $att = new-object Net.Mail.Attachment($html_file)
    $mail.From = $from_address
    $mail.To.Add($to_address)
    $mail.Subject = "Server Diskspace $date"
    $mail.Body = "The diskspace report file is attached."
    $mail.Attachments.Add($att)
    $smtp = New-Object System.Net.Mail.SmtpClient($email_gateway)
    #$smtp.Credentials = New-Object System.Net.NetworkCredential($smtp_user,$smtp_pass)
    $smtp.Send($mail)
    $att.Dispose()
    # Delete the file
    Remove-Item $html_file
    Regards,
    Denis Cooper
    MCITP EA - MCT
    Help keep the forums tidy, if this has helped please mark it as an answer
    My Blog
    LinkedIn:

  • Query to get the data of all the columns in a table except any one column

    Can anyone please tell how to write a query to get the data of all the columns in a table except one particular column..
    For Example:
    Let us consider the EMP table.,
    From this table except the column comm all the remaining columns of the table should be listed
    For this we can write a query like this..
    Select empno, ename, job, mgr, sal, hiredate, deptno from emp;
    Just to avoid only one column, I mentioned all the remaining ( 7 ) columns of the table in the query..
    As the EMP table consists only 8 columns, it doesn't seem much difficult to mention all the columns in the query,
    but if a table have 100 columns in the table, then do we have to mention all the columns in the query..?
    Is there any other way of writing the query to get the required result..?
    Thanks..

    Your best best it to just list all the columns. Any other method will just cause more headaches and complicated code.
    If you really need to list all the columns for a table because you don't want to type them, just use something like...
    SQL> ed
    Wrote file afiedt.buf
      1  select trim(',' from sys_connect_by_path(column_name,',')) as columns
      2  from (select column_name, row_number() over (order by column_id) as column_id
      3        from user_tab_cols
      4        where column_name not in ('COMM')
      5        and   table_name = 'EMP'
      6       )
      7  where connect_by_isleaf = 1
      8  connect by column_id = prior column_id + 1
      9* start with column_id = 1
    SQL> /
    COLUMNS
    EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO
    SQL>

  • Can I get a query to get the output data like 4th column instead of 3rd col

    Can I get a query to get the output data like 4th column instead of 3rd column ?
    SQL&gt; select emp.deptno, empno, rownum from emp, dept where emp.deptno=dept.deptno;
    DEPTNO EMPNO ROWNUM
    10 7782 *1* *1*
    10 7839 *2* *2*
    10 7934 *3* *3*
    20 7369 *4* *1*
    20 7876 *5* *2*
    20 7902 *6* *3*
    20 7788 *7* *4*
    20 7566 *8* *5*
    30 7499 *9* *1*
    30 7698 *10* *2*
    30 7654 *11* *3*
    30 7900 *12* *4*
    30 7844 *13* *5*
    30 7521 *14* *6*
    14 rows selected.

    SQL> select emp.deptno, emp.empno,
      2    row_number() over(order by emp.deptno, emp.empno) rn,
      3    row_number() over(partition by emp.deptno order by emp.empno) dept_rn
      4  from emp, dept
      5  where emp.deptno=dept.deptno
      6  order by emp.deptno, emp.empno;
        DEPTNO      EMPNO         RN    DEPT_RN
            10       7782          1          1
            10       7839          2          2
            10       7934          3          3
            20       7369          4          1
            20       7566          5          2
            20       7788          6          3
            20       7876          7          4
            20       7902          8          5
            30       7499          9          1
            30       7521         10          2
            30       7654         11          3
            30       7698         12          4
            30       7844         13          5
            30       7900         14          6
    14 rows selected.Regards,
    Dima

  • Query to get the windows-user(os)

    Hallo,
    I have a windows operating system and on this system is oracle database with the
    spatial-option installed. Now I wanna create a trigger which writes in a table if
    a geometry is updated. In this table I wanna write the new geometry, the time of
    the update and the windows-user that logged on the windows operating system. I
    don't wanna know the database user.
    What is the sql-query to get the windows-user?
    Thanks Katrin

    As an alternative, use the SYS_CONTEXT function to get some of this info.
    oracle@fuzzy:~> sqlplus test/test@XE
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jan 2 16:32:53 2007
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> select sys_context('USERENV', 'HOST') Host,
      2         sys_context('USERENV', 'IP_ADDRESS') IP,
      3         sys_context('USERENV', 'OS_USER') OS_User,
      4         sys_context('USERENV', 'AUTHENTICATED_IDENTITY') Identity
      5    from dual;
    HOST    IP          OS_USER   IDENTITY
    fuzzy    127.0.0.2  oracle    test
    SQL>                                           More info at http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions165.htm#i1038176

  • Query to get the details of Blocking and deadlock occurred for the Day

    Hi,
       I need a query to get the details of blocking and deadlock occurred for the day.

    You havent specified which version of SQL you are using which makes it difficult to give a solution. Assuming its latest versions , by default SQL Server (in any versions) doesnt track blocking information.
    You need to run some kind of queries/traces to capture blocking. The same goes with Deadlocks where majority of the DBA's enable trace flag 1222/1205 when they suspect deadlocks happening.
    Check this link -
    http://dba.stackexchange.com/questions/10644/deadlock-error-isnt-returning-the-deadlock-sql/10646#10646
    This link gives code to get historic deadlock information. I havent used it , I just googled to get that.
    That being said if you are looking for something to capture for the future check the below links.
    Check these links on how to setup extended events to capture deadlock and blocking.
    http://sqlblog.com/blogs/jonathan_kehayias/archive/2010/12/21/an-xevent-a-day-21-of-31-the-future-tracking-blocking-in-denali.aspx
    http://blogs.msdn.com/b/sqlserverfaq/archive/2013/04/27/an-in-depth-look-at-sql-server-memory-part-2.aspx
    http://blogs.technet.com/b/mspfe/archive/2012/06/28/how_2d00_to_2d00_monitor_2d00_deadlocks_2d00_in_2d00_sql_2d00_server.aspx
    HTH
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • Powershell script to get the domain admin list from non domian member server

    hello Script guys!
    I am new of the powershell scripting.
    currently I am working on autometion project , we would like generate a privilege report for our existing servers.
    in our environment, there are many seprated domain , we would like generate the report from one server instead to login each server to check , could you provide some guide on how can we get the specific domain admin list for each domain from a non domain
    membership server by using the powershell script? many thanks for your help.

    You could remote to the domain controller or use ADSI to query the domain.
    Look inth eGallery as ther eare many scripts there tha will return group membership using ADSI.
    ¯\_(ツ)_/¯

  • Need Store DB tables to query to get the latest scanned price at register

    Need Store DB tables to query to get the latest scanned price at register.
    Please provide a sample sql script that will help me do this. I need to have this informatino for several items at a time.
    Thanks,
    Edited by: user10133807 on Jan 13, 2012 9:22 AM
    Edited by: user10133807 on Jan 13, 2012 9:23 AM

    Hi,
    You can find multiple items saled price at the register by running below quary
    select distinct DC_DY_BSN,ID_ITM_POS,MO_PRN_PRC from TR_LTM_SLS_RTN;
    Thanks,
    MG

  • How to modify the query to get the output in a single row

    Hi All,
    Below is the query i have written it works fine
    select DISTINCT right(left(CTACCT,13),4) AS LocationNum,
    tODS_GLBalance.FiscalYearId AS FiscalYearId,
    tODS_GLBalance.FiscalMonthOfYearId AS FiscalMonthOfYearId,
    --tods_GLMetadata.Metric,
    Case when
    tods_GLMetadata.Metric = 'Gross Margin'
    Then SUM(Balance)
    Else 0
    END AS GrossMargin,
    Case when
    tods_GLMetadata.Metric = 'Occupancy'
    Then SUM(Balance)
    Else 0
    END AS Occupancy,
    Case when
    tods_GLMetadata.Metric = 'Payroll Dollars'
    Then SUM(Balance)
    Else 0
    END AS Payroll,
    Case when
    tods_GLMetadata.Metric = 'CF Sales'
    Then SUM(Balance)
    Else 0
    END AS OperatingSales,
    Case when
    tods_GLMetadata.Metric = 'Operations'
    Then SUM(Balance)
    Else 0
    END AS OperatingExpenses
    -- 0 as payroll
    from ods.[JJill].[tODS_GLBalance]
    inner join ods.Staging.tODS_INF_GLPCT ON tODS_GLBalance.PageNum = tODS_INF_GLPCT.CTPAGE
    inner join ods.JJill.tods_GLMetadata ON tods_GLMetadata.AcctDescription = tODS_INF_GLPCT.CTDESC
    where
    (tODS_GLBalance.FiscalYearId = 2012) and
    (tODS_GLBalance.FiscalMonthOfYearId = 2) and
    (right(left(CTACCT,13),4)= 3020)
    group by
    right(left(CTACCT,13),4),
    tODS_GLBalance.FiscalYearId,
    tODS_GLBalance.FiscalMonthOfYearId,
    tods_GLMetadata.Metric
    This is the sample output,
    LocationNum FiscalYearId FiscalMonthOfYearId GrossMargin Occupancy Payroll OperatingSales OperatingExpenses
    3020 2012 2 -112477.00 0.00 0.00 0.00 0.00
    3020 2012 2 0.00 0.00 0.00 -158288.94 0.00
    3020 2012 2 0.00 0.00 0.00 0.00 5625.44
    3020 2012 2 0.00 0.00 24185.79 0.00 0.00
    3020 2012 2 0.00 31075.53 0.00 0.00 0.00
    But, i am expecting the output to be something like this
    LocationNum FiscalYearId FiscalMonthOfYearId GrossMargin Occupancy Payroll OperatingSales OperatingExpenses
    3020 2012 2 -112477.00 31075.53 24185.79 -158288.94 5625.44
    Can someone please help me with changing my query to get the desired output?
    Please let me know if you have any questions.
    Thanks

    Try this:
    SELECT DISTINCT
    RIGHT(LEFT(CTACCT,13),4) AS LocationNum, tODS_GLBalance.FiscalYearId AS FiscalYearId, tODS_GLBalance.FiscalMonthOfYearId AS FiscalMonthOfYearId,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Gross Margin' THEN Balance ELSE 0 END ) AS GrossMargin,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Occupancy' THEN Balance ELSE 0 END ) AS Occupancy,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Payroll Dollars' THEN Balance ELSE 0 END ) AS Payroll,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'CF Sales' THEN Balance ELSE 0 END ) AS OperatingSales,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Operations' THEN Balance ELSE 0 END ) AS OperatingExpenses
    FROM ods.[JJill].[tODS_GLBalance]
    INNER JOIN ods.Staging.tODS_INF_GLPCT
    ON tODS_GLBalance.PageNum = tODS_INF_GLPCT.CTPAGE
    INNER JOIN ods.JJill.tods_GLMetadata
    ON tods_GLMetadata.AcctDescription = tODS_INF_GLPCT.CTDESC
    WHERE tODS_GLBalance.FiscalYearId = 2012
    AND tODS_GLBalance.FiscalMonthOfYearId = 2
    AND RIGHT(LEFT(CTACCT,13),4) = 3020
    GROUP BY right(left(CTACCT,13),4), tODS_GLBalance.FiscalYearId, tODS_GLBalance.FiscalMonthOfYearId, tods_GLMetadata.Metric

  • Steps of abap query--- to get the reports

    steps of abap query -
    to get the reports

    Hi Deva,
    For step by step procedure to create an ABAP query you can refer to the following links
    http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Introduction.asp
    http://allaboutsap.blogspot.com/2007/09/sap-query-step-by-step.html

  • PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.

    Hi Experts,
    I am trying to  build a PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.
    Can anyone advise on this please.
    Regards

    Get-SPSolution|Select Name,Scope,LastOperationResult,LastOperationEndTime|Export-CSV "SPInstalledSolutions.csv" -NoTypeInformation
    SPSolution properties
    Get-SPSolution
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Query to get the hierarchical results

    Hi,
    Please help me in writing a Query to get the hierarchical results. I want a result like follows...
    course-----groupname---TotalMembers---NotStarted---INProgress---Completed
    Course1---country1--------12---------------6----------3-------------3
    Course1-----state11-------12---------------6----------3-------------3
    Course1------District111--10---------------5----------0-------------0
    Course1--------City1111----0---------------0----------0-------------0
    Course1--------City1112----1---------------0----------0-------------1
    Course1--------City1113----6---------------3----------2-------------1
    Course1---country2--------12---------------6----------3-------------3
    Course1----state21--------12---------------6----------3-------------3
    Course1------District211--10---------------5----------0-------------0
    Course1--------City2111----0---------------0----------0-------------0
    Course1--------City2112----1---------------0----------0-------------1
    Course1--------City2113----6---------------3----------2-------------1
    Course2---country1--------12---------------6----------2-------------3
    Course2----state11--------12---------------6----------2-------------3
    Course2------District111--10---------------5----------0-------------0
    Course2--------City1111----0---------------0----------0-------------0
    Course2--------City1112----1---------------0----------0-------------1
    Course2--------City1113----6---------------3----------1-------------2
    Course2---country2--------12---------------6----------3-------------3
    Course2-----state21-------12---------------6----------3-------------3
    Course2------District211--10---------------5----------0-------------0
    Course2--------City2111----0---------------0----------0-------------0
    Course2--------City2112----1---------------0----------0-------------1
    Course2--------City2113----6---------------3----------2-------------1
    These are the Tables available to me.
    (I have just given some examle data in tables, to get the idea)
    "Groups" Table (This table gives the information of the group)
    GROUPID-----NAME-------PARENTID
    1---------Universe--------1
    2---------country1--------1
    3---------state11---------2
    4---------District111-----3
    5---------City1111--------4
    6---------City1112--------4
    7---------City1113--------4
    8---------country2--------1
    9---------state21---------8
    10--------District211-----9
    11--------City2111--------10
    12--------City2112--------10
    13--------City2113--------10
    "Users" Table (This table provides the user information)
    userID----FIRSTNAME---LASTNAME
    user1-----------Jim-------Carry
    user2-----------Tom-------lee
    user3-----------sunny-----boo
    user4-----------mary------mall
    "User-Group" Tables (This table provides the relation between the groups
    and the members)
    GROUPID---userID
    3-------------user1
    3-------------user2
    3-------------user4
    4-------------user5
    5-------------user6
    5-------------user7
    user_score (This table provides the user scores of different courses)
    USERID----course-----STATUS
    user1------course1-----complete
    user1------course2-----NotStarted
    user2------course1-----NotStarted
    user2------course2-----complete
    user3------course1-----complete
    user3------course2-----InProgress
    user4------course2-----complete
    user4------course1-----NotStarted
    I will explain the first four lines of the above result.
    Course1---country1--------12---------------6----------4-------------2
    Course1-----state11-------12---------------6----------4-------------2
    Course1------District111--10---------------5----------3-------------2
    Course1--------City1111----0---------------0----------0-------------0
    Course1--------City1112----1---------------0----------0-------------1
    Course1--------City1113----6---------------3----------2-------------1
    # "city1111" group has 0 members
    # "city1112" group has 1 member (1 member completed the course1)
    # "city1113" group has 6 members(3 members notStarted,2 members
    InProgress,1 member completed the course1)
    # "District111" is the parent group of above three groups, and has 3
    members.(2 members NotStarted,1 member InProgress the course1). But this
    group has child groups, so the scores of this group has to rollup the
    child groups scores also. Thats why it has 2+3+0+0=6 members Not
    Started,1+2+0+0=3 members InProgress,0+0+1+1=2 members completed.
    # "state11" group also same as the above group.
    I am able to get the group hierarchy by using "Connect By" like follows
    "select name,groupid,parentid from groups_info start with groupid=1 connect by parentid = prior groupid;"
    But i want to get the result as i have mentioned in the begining of this discussion.
    I am using oracle 8i (oracle8.1.7).
    Thank you for any help
    Srinivas M

    This may not be exactly what you want,
    but it should be fairly close:
    SET      LINESIZE 100
    SET      PAGESIZE 24
    COLUMN   groupname FORMAT A20
    SELECT   INITCAP (user_score.course) "course",
             groupnames.name "groupname",
             COUNT (*) "TotalMembers",
             SUM (NVL (DECODE (UPPER (user_score.status), 'NOTSTARTED', 1), 0)) "NotStarted",
             SUM (NVL (DECODE (UPPER (user_score.status), 'INPROGRESS', 1), 0)) "InProgress",
             SUM (NVL (DECODE (UPPER (user_score.status), 'COMPLETE', 1), 0)) "Completed"
    FROM     user_score,
             user_group,
             (SELECT ROWNUM rn,
                     name,
                     groupid
              FROM   (SELECT     LPAD (' ', 2 * LEVEL - 2) || name AS name,
                                 groupid
                      FROM       groups
                      START WITH groupid = 1
                      CONNECT BY PRIOR groupid = parentid)) groupnames
    WHERE    user_score.userid = user_group.userid
    AND      user_group.groupid IN
             (SELECT     groupid
              FROM       groups
              START WITH groupid = groupnames.groupid
              CONNECT BY PRIOR groupid = parentid)
    GROUP BY user_score.course, groupnames.name, groupnames.rn
    ORDER BY user_score.course, groupnames.rn
    I entered the minimal test data that you
    provided and a bit more and got this result
    (It was formatted as you requested,
    but I don't know if it will display properly
    on this post, or wrap around):
    course  groupname            TotalMembers NotStarted InProgress  Completed
    Course1 Universe                        6          2          0          4
    Course1   country1                      5          2          0          3
    Course1     state11                     5          2          0          3
    Course1       District111               2          0          0          2
    Course1         City1112                1          0          0          1
    Course1         City1113                1          0          0          1
    Course1   country2                      1          0          0          1
    Course1     state21                     1          0          0          1
    Course1       District211               1          0          0          1
    Course1         City2113                1          0          0          1
    Course2 Universe                        5          1          1          3
    Course2   country1                      4          1          1          2
    Course2     state11                     4          1          1          2
    Course2       District111               1          0          1          0
    Course2         City1113                1          0          1          0
    Course2   country2                      1          0          0          1
    Course2     state21                     1          0          0          1
    Course2       District211               1          0          0          1
    Course2         City2113                1          0          0          1
    Here is the test data that I used, in case
    anyone else wants to play with it:
    create table groups
      (groupid  number,
       name     varchar2(15),
       parentid number)
    insert into groups
    values (1,'Universe',null)
    insert into groups
    values (2,'country1',1)
    insert into groups
    values (3,'state11',2)
    insert into groups
    values (4,'District111',3)
    insert into groups
    values (5,'City1111',4)
    insert into groups
    values (6,'City1112',4)
    insert into groups
    values (7,'City1113',4)
    insert into groups
    values (8,'country2',1)
    insert into groups
    values (9,'state21',8)
    insert into groups
    values (10,'District211',9)
    insert into groups
    values (11,'City2111',10)
    insert into groups
    values (12,'City2112',10)
    insert into groups
    values (13,'City2113',10)
    create table user_group
      (groupid number,
       userid  varchar2(5))
    insert into user_group
    values (3,'user1')
    insert into user_group
    values (3,'user2')
    insert into user_group
    values (3,'user4')
    insert into user_group
    values (4,'user5')
    insert into user_group
    values (5,'user6')
    insert into user_group
    values (5,'user7')
    insert into user_group
    values (7,'user8')
    insert into user_group
    values (13,'user9')
    insert into user_group
    values (11,'use11')
    insert into user_group
    values (6,'use6')
    create table user_score
      (userid varchar2(5),
       course varchar2(7),
       status varchar2(10))
    insert into user_score
    values ('use6','course1','complete')
    insert into user_score
    values ('user9','course1','complete')
    insert into user_score
    values ('user9','course2','complete')
    insert into user_score
    values ('user8','course1','complete')
    insert into user_score
    values ('user8','course2','InProgress')
    insert into user_score
    values ('user1','course1','complete')
    insert into user_score
    values ('user1','course2','NotStarted')
    insert into user_score
    values ('user2','course1','NotStarted')
    insert into user_score
    values ('user2','course2','complete')
    insert into user_score
    values ('user3','course1','complete')
    insert into user_score
    values ('user3','course2','InProgress')
    insert into user_score
    values ('user4','course2','complete')
    insert into user_score
    values ('user4','course1','NotStarted')

Maybe you are looking for

  • ITunes Asking for Authorization to Play Downloaded Song

    I am having a problem I've never had before.  iTunes won't play a song I downloaded 11.0.4 won't play a song I downloaded from the iTunes Store as part of an album.  It asks to authorize the computer to play the song.  When I enter my name and passwo

  • BP Activity Query

    Hi All -- Can someone help us with a Query where we can select by Activity creation date range.  After selecting range, the Query should pull all "Other Activities" and show the following info: BP Acct#...Contact...Company...Bill To Address...Bill To

  • Adding line items in BAPI_PO_CHANGE

    Hi, i am using BAPI_PO_CHANGE and i have already created po line item under one PO. Now i want to add more line items under the same document number. How can i do that using BAPI_PO_CHANGE. Thanks

  • How do I restore my mac mini and back up selected files

    Hi everyone, I have a question as I'm a little uncertain how to handle this: I have a Mac Mini 2011, Processor  2 GHz Intel Core i7, Memory  4 GB 1333 MHz DDR3, Software  OS X 10.9.4 (13E28), with SATA Disks of 500GB each.  I have noticed it remarkab

  • Changing the label of attributes configured on User Profile by SAP HRMS connector

    Is it possible to change the label of attributes configured on User Profile by SAP HRMS connector during the installation?