Group by having clause problem

Hi,
I have a query like this:
select a.id,a.first_nm,a.last_nm,a.subgroup_id
from temp a
where (a.subgroup_id like 'D%' or a.subgroup_id like 'G%')
group by a.id,a.first_nm,a.last_nm,a.subgroup_id having
count(*) >1
union
select b.id,b.first_nm,b.last_nm,b.subgroup_id
from temp b
where b. subgroup_id like 'F%'
group by b.id,b.first_nm,b.last_nm,b.subgroup_id having count(*) > 2;
I want the result like this:
10001 Wendy Lin DAP
10001 Wendy Lin GMP
10002 Jim Davis FAD
10002 Jim Davis FIP
10002 Jim Davis FIAP
My query above didn't give the right result, Can someone help me?
Thank you very much!
Wendy

You may like to try this way...
select id,name,sub_id
from a
where id in (select id
from a
group by id
having count(id)>1)
order by id,name, sub_id asc;
results are..
ID NAME CODE
1 wendy DIA
1 wendy LCA
1 wendy PLA
2 jim CPR
2 jim DIA
2 jim PLA
Hope this helps.

Similar Messages

  • Urgent Group by Having Clause Fails in Oracle and Works in Sybase

    Hello EveryBody I need to select curve data of curve whose date is maximum in that curve so say if i ahve
    so if records are
    curveid curvename curvedate
    1001 test1 12/12/1003
    1001 test1 12/13/1003
    1002 test2 12/12/2002
    1002 test2 12/12/2004
    I have query which run well in sybase but oracle screw up...My logic say having clause is use to filter the records of group so it should have worked in oracle.....
    Here is query
    select curveid,curvename from curve group by curveid having curvedate =max(curve_date)
    This give "not a Group by " error in oracle....It work well in sybase...
    ORA-00979: not a GROUP BY expression
    I have query which use subquery to select these records but i don't want that to use that query
    Please help

    please understand what I need the result
    for each curve i need that data of that curve who date is max in that curve group
    so say for 1001 there are two date 1/1/2001 and 1/1/2002
    I need the data of curve 1001 with date 1/1/2002
    Oracle should have some alternative solution for this....
    If i have to use subquery I do have subquery
    select a.curveid, b.curvename from curve a group by curveid having curvedate = (select max(curvedate) from curve where a.curveid=b.curveid group by curveid );
    I don't want to use that ,,,
    I want to solve my probelm using having and group/....
    Main purpose of having is to filter the records from group result so IT SHOULD DO THAT WHY ORACLE GIVE ORA ERROR FOR
    group by curve_id having curve_date=max(curve_date)
    Creators of oracle please reply

  • Group By -- Having Clause related doubt.

    Hello,
    Can we Write/Use rather a 'Having Condition' Before a Group by Clause ..?
    If Yes then How does it Work.. I mean a 'Having' is a WHERE clause (filter) on Aggregate results ...
    SO how does Having works before grouping the Results..??

    Hi,
    Aijaz Mallick wrote:
    Hello,
    Can we Write/Use rather a 'Having Condition' Before a Group by Clause ..?What happens when you try it?
    If Yes then How does it Work.. I mean a 'Having' is a WHERE clause (filter) on Aggregate results ... Right; the HAVING clause is like another WHERE clause.
    The WHERE clause is applied before the GROUP BY is done, and the aggregate functions are computed.
    The HAVING clause is applied after the GROUP BY is done, and the aggregate functions are computed, so you can use aggregate functions in the HAVING clause.
    SO how does Having works before grouping the Results..??The order in which clauses appear in your code isn't necessarily the order in which they are performed. For example,
    SELECT    job
    ,         COUNT (*)  AS cnt
    FROM      scott.emp
    GROUP BY  job;Does it confuse you that this query can reference COUNT (*) in the SLECT clause, which is before the GROUP BY clause?
    The SELECT clause which always comes before the GROUP BY clause in code. That does not mean that the SELECT clause is completed before the GROUP BY clause is begun.
    If the documentation says that clauses must be in a certain order, then use that order, even if your current version of Oracle allows them to be in a different order. There's no guarantee that the next version of Oracle will allow something that was always said to be wrong.

  • Having multiple problems with script - NTFS Permissions and AD Groups

    Hi, all!  I'm having multiple problems with my first script I've written with Powershell.  The script below does the following:
    1. Prompts the user for a corporate division under which a shared folder will be created, and adjusts variables accordingly.
    2. Prompts if the folder will be a global folder or an office/location-specific folder, and makes appropriate adjustments to variables.
    3.  If a global folder, prompts for the name.  If an office/location-specific folder, prompts for each component of the street address, city and state and an optional modifier.  I've prompted for this information in this way because the information
    is used differently later on in the script.
    4.  Verifies the entered information and requests confirmation to proceed.
    5.  Creates the folder.
    6.  Creates an AD OU and/or security group(s).
    7.  Applies appropriate security groups to the new folder and removes undesired permissions.
    Import-Module ActiveDirectory
    $Division = ""
    $DivAbbr = ""
    $OU = ""
    $OUDrive = "AD:\"
    $FolderName = ""
    $OUName = ""
    $GroupName = ""
    $OURoot = "ou=DFS Restructure Testing OU,ou=Pennsylvania Camp Hill 4410 Industrial Park Rd,ou=Locations,ou=Camp Hill,dc=jacobsonco,DC=com"
    $FSRoot = "E:\"
    $FolderPath = ""
    $DefaultFolders = "Archive","Customer Service","Equipment","Inbounds","Management","Outbounds","Processes","Projects","Quality","Reports","Returns","Safety","Schedules","Time Keeping","Training"
    [bool]$Location = 0
    do {
    $userInput = Read-Host "Enter CLS Division: (W)arehousing, (S)taffing, or (P)ackaging"
    Switch ($userInput)
    W {$Division = "Warehousing"; $DivAbbr = "WHSE"; $OU = "ou=Warehousing,"; break}
    S {"Staffing is not yet implemented."; break}
    P {"Packaging is not yet implemented."; break}
    default {"Invalid choice. Please re-enter."; break}
    while ($DivAbbr -eq "")
    write-host ""
    write-host ($Division + " was selected.")
    $FolderPath = $Division + "\"
    write-host ""
    $choice = ""
    do {
    $choice = Read-Host "Will this be a (G)lobal folder or (L)ocation folder?"
    Switch ($choice)
    G {$Location = $false; break}
    L {$Location = $true; $FolderPath = $FolderPath + "Locations\"; $OU = "ou=Locations," + $OU; break}
    default {"Invalid choice. Please re-enter."; $choice = ""; break}
    while ($choice -eq "")
    write-host ""
    write-host ("Location is set to: " + $Location)
    write-host ""
    if ($Location -eq $false) {
    $FolderName = Read-Host "Please enter folder name:"
    $GroupName = $DivAbbr + " " + $FolderName
    } else {
    $input = Read-Host "Please enter two-letter state abbreviation:"
    $FolderName = $FolderName + $input + " "
    $input = Read-Host "Please enter city:"
    $FolderName = $FolderName + $input + " "
    $input = Read-Host "Please enter street address number only:"
    $FolderName = $FolderName + $input
    $GroupName = $DivAbbr + " " + $FolderName
    $FolderName = $FolderName + " "
    $input = Read-Host "Please enter street name:"
    $FolderName = $FolderName + $input
    $input = Read-Host "Please enter any optional information to appear in folder name:"
    if ($input -ne "") {
    $FolderName = $FolderName + " " + $input
    $OUName = $FolderName
    write-host
    write-host "Path for folder: "$FSRoot$FolderPath$FolderName
    write-host "AD Path: "$OUDrive$OU$OURoot
    write-host "New OU Name: "$OUName
    write-host -NoNewLine "New Security Group names: "$GroupName
    if ($Location -eq $true) { write-host " and "$GroupName" MGMT" }
    write-host
    $input = Read-Host "Please confirm creation of new site/folder: (Y/N) "
    if ($input -ne "Y") { Exit }
    write-host
    write-host -NoNewLine "Folder exists: "; Test-Path ($FSRoot + $FolderPath + $FolderName)
    if (Test-Path ($FSRoot + $FolderPath + $FolderName)) {
    Write-Host "Folder already exists! Skipping folder creation..."
    } else {
    write-host "Folder does not exist. Creating..."
    new-item -path ($FSRoot + $FolderPath) -name $FolderName -itemtype directory
    Set-Location ($FSRoot + $FolderPath + $FolderName)
    if ($Location -eq $true) {
    $tempOUName = "ou=" + $OUName + ","
    write-host
    write-host $OUDrive$tempOUName$OU$OURoot
    write-host
    write-host -NoNewLine "OU exists: "; Test-Path ($OUDrive + $tempOUName + $OU + $OURoot)
    if (Test-Path ($OUDrive + $tempOUName + $OU + $OURoot)) {
    Write-Host "OU already exists! Skipping OU creation..."
    } else {
    write-host "OU does not exist. Creating..."
    New-ADOrganizationalUnit -Name $OUName -Path ($OU + $OURoot) -ProtectedFromAccidentalDeletion $false
    $GroupNameMGMT = $GroupName + " MGMT"
    if (!(Test-Path ($OUDrive + "CN=" + $GroupName + "," + $tempOUName + $OU + $OURoot))) { write-host "Normal user group does not exist. Creating..."; New-ADGroup -Name $GroupName -GroupCategory Security -GroupScope Global -Path ("OU=" + $OUName + "," + $OU + $OURoot)}
    if (!(Test-Path ($OUDrive + "CN=" + $GroupNameMGMT + "," + $tempOUName + $OU + $OURoot))) { write-host "Management user group does not exist. Creating..."; New-ADGroup -Name $GroupNameMGMT -GroupCategory Security -GroupScope Global -Path ("OU=" + $OUName + "," + $OU + $OURoot)}
    $FolderACL = get-acl ($FSRoot + $FolderPath + $FolderName)
    $FolderACL.SetAccessRuleProtection($True,$True)
    # $FolderACL.Access | where {$_.IdentityReference -eq "BUILTIN\Users"} | %{$FolderACL.RemoveAccessRuleAll($_)}
    $BIUsers = New-Object System.Security.Principal.NTAccount("BUILTIN\Users")
    $BIUsersSID = $BIUsers.Translate([System.Security.Principal.SecurityIdentifier])
    write-host $BIUsersSID.Value
    # out-string -inputObject $BIUsers
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($BIUsersSID.Value,"ReadAndExecute,AppendData,CreateFiles,Synchronize","ContainerInherit, ObjectInherit", "None", "Allow")
    $FolderACL.RemoveAccessRuleAll($Ar)
    Set-ACL ($FSRoot + $FolderPath + $FolderName) $FolderACL
    get-acl ($FSRoot + $FolderPath + $FolderName) | fl
    $FolderACL = get-acl ($FSRoot + $FolderPath + $FolderName)
    $ADGroupName = "JACOBSON\" + $GroupName
    $objUser = New-Object System.Security.Principal.NTAccount($ADGroupName)
    $objUser.Translate([System.Security.Principal.SecurityIdentifier]).Value
    write-host $ADGroupName
    write-host $objUser.Value
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($ADGroupName,"ReadAndExecute","ContainerInherit, ObjectInherit", "None", "Allow")
    Out-String -InputObject $ar
    $FolderACL.AddAccessRule($Ar)
    $ADGroupName = "JACOBSON\" + $GroupNameMGMT
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($ADGroupName, "Modify", "ContainerInherit, ObjectInherit", "None", "Allow")
    Out-String -InputObject $ar
    $FolderACL.AddAccessRule($Ar)
    Set-ACL ($FSRoot + $FolderPath + $FolderName) $FolderACL
    } else {
    $tempOUName = "cn=" + $GroupName + ","
    write-host
    write-host $OUDrive$tempOUName$OU$OURoot
    write-host
    write-host -NoNewLine "Group exists: "; Test-Path ($OUDrive + $tempOUName + $OU + $OURoot)
    if (Test-Path ($OUDrive + $tempOUName + $OU + $OURoot)) {
    Write-Host "Security group already exists! Skipping new security group creation..."
    } else {
    write-host "Security group does not exist. Creating..."
    New-ADGroup -Name $GroupName -GroupCategory Security -GroupScope Global -Path ($OU + $OURoot)
    $FolderACL = get-acl ($FSRoot + $FolderPath + $FolderName)
    $ADGroupName = "JACOBSON\" + $GroupName
    $FolderACL.SetAccessRuleProtection($True,$True)
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($ADGroupName,"Modify","ContainerInherit, ObjectInherit", "None", "Allow")
    $FolderACL.AddAccessRule($Ar)
    $FolderACL.Access | where {$_.IdentityReference -eq "BUILTIN\Users"} | %{$FolderACL.RemoveAccessRuleAll($_)}
    Set-ACL ($FSRoot + $FolderPath + $FolderName) $FolderACL
    My problems right now are in the assignment/removal of security groups on the newly-created folder, and the problems are two-fold.  Yes, I am running this script as an Administrator.
    First, I am unable to remove the BUILTIN\Users group from the folder when this is an office/location-specific folder.  I've tried to remove the group in several different ways, and none are having any effect.  Oddly, if I type in the lines directly
    into Powershell, they work as expected.  I've tried the following methods:
    $FolderACL = get-acl ($FSRoot + $FolderPath + $FolderName)
    $FolderACL.SetAccessRuleProtection($True,$True)
    $FolderACL.Access | where {$_.IdentityReference -eq "BUILTIN\Users"} | %{$FolderACL.RemoveAccessRuleAll($_)}
    Set-ACL ($FSRoot + $FolderPath + $FolderName) $FolderACL
    $FolderACL = get-acl ($FSRoot + $FolderPath + $FolderName)
    $FolderACL.SetAccessRuleProtection($True,$True)
    $BIUsers = New-Object System.Security.Principal.NTAccount("BUILTIN\Users")
    $BIUsersSID = $BIUsers.Translate([System.Security.Principal.SecurityIdentifier])
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($BIUsersSID.Value,"ReadAndExecute,AppendData,CreateFiles,Synchronize","ContainerInherit, ObjectInherit", "None", "Allow")
    $FolderACL.RemoveAccessRuleAll($Ar)
    Set-ACL ($FSRoot + $FolderPath + $FolderName) $FolderACL
    In the first case, the script goes through and has no apparent effect because afterwards, I do a get-acl and the BUILTIN\Users group is still there, although when looking through the GUI, inheritance appears to have been broken from the parent folder.
    In the second case, I get the following error message:
    Exception calling "RemoveAccessRuleAll" with "1" argument(s): "Some or all identity references could not be translated."
    At C:\Users\tesdallb\Documents\FileServerBuild.ps1:110 char:5
    +     $FolderACL.RemoveAccessRuleAll($Ar)
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : IdentityNotMappedException
    This seems strange that the local server is unable to translate the SID of a BUILTIN account.  I've also tried explicitly putting in the BUILTIN\Users SID in place of the variable in the New-Object line, but that gives me the same error.  I've
    also tried the solutions given in this thread:
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/ad59dc58-1360-4652-ae09-2cd4273cbd4f/remove-acl-issue?forum=winserverpowershell and at this URL:
    http://technet.microsoft.com/en-us/library/ff730951.aspx but these solutions also failed to have any effect.
    My second problem is when I try to apply the newly-created security groups, I also will get the "Some or all identity references could not be translated."  I thought I had found a workaround to the problem by adding the -PassThru option to
    the New-ADGroup commands, because it would output the SID of the group after creation, however a few lines later, the server is unable to translate the account to apply the security groups to the folder.
    My first Powershell script has been working well up to this point and now I seem to have hit a showstopper.  Any help is appreciated.
    Thanks!

    I was hoping to stay with strictly Powershell, but unless I can find a Powershell solution, I may resort to ICACLS.
    As for the problems with my groups not being translatable right after creating them, I think I have solved this problem by using the -Server parameter on all my New-ADGroup commands and this example code seems to have gotten around the translation problem,
    again utilizing the -Server parameter on the Get-ADGroup command:
    get-acl ($FSRoot + $FolderPath + $FolderName) | fl
    $FolderACL = get-acl ($FSRoot + $FolderPath + $FolderName)
    # Add the new normal users group to the folder with Read and Execute permissions
    $GroupSID = Get-ADGroup -Identity $GroupName -Server chadc01.jacobsonco.com | Select-Object -ExpandProperty SID
    $SIDIdentity = New-Object System.Security.Principal.SecurityIdentifier($GroupSID)
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($SIDIdentity,"ReadAndExecute","ContainerInherit, ObjectInherit", "None", "Allow")
    $FolderACL.AddAccessRule($Ar)
    # Add the management users group to the folder with Modify permissions
    $GroupMGMTSID = Get-ADGroup -Identity $GroupNameMGMT -Server chadc01.jacobsonco.com | Select-Object -ExpandProperty SID
    $SIDIdentity = New-Object System.Security.Principal.SecurityIdentifier($GroupMGMTSID)
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($SIDIdentity, "Modify", "ContainerInherit, ObjectInherit", "None", "Allow")
    $FolderACL.AddAccessRule($Ar)
    Set-ACL ($FSRoot + $FolderPath + $FolderName) $FolderACL
    Going this route seems to ensure that the Domain Controller I'm creating my groups on is the same one that I'm querying for the group's SID to use in the FileSystemAccessRule.  It's been working fairly consistently.
    Still having issues with the translation of the BUILTIN\Users group, though. 

  • Use of group by and having clause

    hi frnds
    can anybody explain me the use of group by an having clause in select state ment

    Hi Rohit,
    1. GROUP BY f1 ... fn
    2. GROUP BY (itab)
    1. GROUP BY f1 ... fn
    Effect
    Groups database table data in a SELECT command on one line in the result set. A group is a set of lines which all have the same values in each column determined by the field descriptors f1 ... fn.
    ... GROUP BY f1 ... fn always requires a list in the SELECT clause. If you use field descriptors without an aggregate funciton in the SELECT clause, you must list them in the GROUP BY f1 ... fn clause.
    Example
    Output the number of passengers, the total weight and the average weight of luggage for all Lufthansa flights on 28.02.1995:
    TABLES SBOOK.
    DATA:  COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
    DATA:  CONNID LIKE SBOOK-CONNID.
    SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
           INTO (CONNID, COUNT, SUM, AVG)
           FROM SBOOK
           WHERE
             CARRID   = 'LH'       AND
             FLDATE   = '19950228'
           GROUP BY CONNID.
      WRITE: / CONNID, COUNT, SUM, AVG.
    ENDSELECT.
    Note
    ... GROUP BY f1 ... fn is not supported for pooled and cluster tables.
    2. GROUP BY (itab)
    Effect
    Works like GROUP BY f1 ... fn if the internal table itab contains the list f1 ... fn as ABAP source code. The internal table itab can only have one field. This field must be of the type C and should not be more than 72 characters long. itab must be enclosed in parentheses and there should be no blanks between the parentheses and the table name.
    Note
    The same restrictions apply to this variant as to GROUP BY f1 ... fn.
    Example
    Output all Lufthansa departure points with the number of destinations:
    TABLES: SPFLI.
    DATA:   BEGIN OF WA.
              INCLUDE STRUCTURE SPFLI.
    DATA:     COUNT TYPE I.
    DATA:   END OF WA.
    DATA:   WA_TAB(72) TYPE C,
            GTAB LIKE TABLE OF WA_TAB,
            FTAB LIKE TABLE OF WA_TAB,
            COUNT TYPE I.
    CLEAR: GTAB, FTAB.
    WA_TAB = 'COTYFROM COUNT( * ) AS COUNT'. APPEND FTAB.
    APPEND WA_TAB TO FTAB.
    WA_TAB = 'CITYFROM'.
    APPEND WA_TAB TO GTAB.
    SELECT DISTINCT (FTAB)
           INTO CORRESPONDING FIELDS OF WA
           FROM SPFLI
           WHERE
             CARRID   = 'LH'
           GROUP BY (GTAB).
      WRITE: / WA-CITYFROM, WA-COUNT.
    ENDSELECT.
    Regards,
    Susmitha

  • How to have Having clause in Group by

    Hi All,
    While using aggregated function (max,min etc) on columns, the SQL generated automatically has the non aggregated columns in the group by clause. How to specify the Having condition ?
    select a , max(b)
    from t
    group by a
    having <condition>
    TIA...

    Hi,
    In your interface drag and drop the source column into canvas for which you want to generate the HAVING clause.
    It will create filters for those columns .Now use aggregation functions like SUM, MAX,MIN, AVG etc in that filter query .
    The code generated will now contain the HAVING clause in it .
    Thanks,
    Sutirtha

  • Lync 2013 I have a strange problem concerning group call pickup in lync 2013.the pickup calls on snom 710 having only a second delay, but in lync client it having about 5-7 second Anybody out there having similar problems with call pickup Groups?

    HI
    I have a strange problem concerning  group call pickup  in lync 2013.the pickup calls on snom 710 having only a second delay, but in lync client it having  about 5-7 second
    Anybody out there having similar problems with call pickup Groups?

    Hi,
    Did you meet any other call delay when you using Lync?
    As the issue happen for Lync desktop client, it can be performance issue. Please check if there is any error message from FE Server when the issue happen.
    Also please check if you have updated Lync Server to the latest version, if not, update it and then test again.
    Best Regards,
    Eason Huang  
    Eason Huang
    TechNet Community Support

  • Group by clause and having clause in select

    hi frnds
    plz give me some information of group by and having clause used in select statement with example
    thanks

    The Open SQL statement for reading data from database tables is:
    SELECT      <result>
      INTO      <target>
      FROM      <source>
      [WHERE    <condition>]
      [GROUP BY <fields>]
      [HAVING   <cond>]
      [ORDER BY <fields>].
    The SELECT statement is divided into a series of simple clauses, each of which has a different part to play in selecting, placing, and arranging the data from the database.
    You can only use the HAVING clause in conjunction with the GROUP BY clause.
    To select line groups, use:
    SELECT <lines> <s1> [AS <a1>] <s2> [AS <a2>] ...
                   <agg> <sm> [AS <am>] <agg> <sn> [AS <an>] ...
           GROUP BY <s1> <s2> ....
           HAVING <cond>.
    The conditions <cond> that you can use in the HAVING clause are the same as those in the SELECT clause, with the restrictions that you can only use columns from the SELECT clause, and not all of the columns from the database tables in the FROM clause. If you use an invalid column, a runtime error results.
    On the other hand, you can enter aggregate expressions for all columns read from the database table that do not appear in the GROUP BY clause. This means that you can use aggregate expressions, even if they do not appear in the SELECT clause. You cannot use aggregate expressions in the conditions in the WHERE clause.
    As in the WHERE clause, you can specify the conditions in the HAVING clause as the contents of an internal table with line type C and length 72.
    Example
    DATA WA TYPE SFLIGHT.
    SELECT   CONNID
    INTO     WA-CONNID
    FROM     SFLIGHT
    WHERE    CARRID = 'LH'
    GROUP BY CONNID
    HAVING   SUM( SEATSOCC ) > 300.
      WRITE: / WA-CARRID, WA-CONNID.
    ENDSELECT.
    This example selects groups of lines from database table SFLIGHT with the value ‘LH’ for CARRID and identical values of CONNID. The groups are then restricted further by the condition that the sum of the contents of the column SEATSOCC for a group must be greater than 300.
    The <b>GROUP BY</b> clause summarizes several lines from the database table into a single line of the selection.
    The GROUP BY clause allows you to summarize lines that have the same content in particular columns. Aggregate functions are applied to the other columns. You can specify the columns in the GROUP BY clause either statically or dynamically.
    Specifying Columns Statically
    To specify the columns in the GROUP BY clause statically, use:
    SELECT <lines> <s1> [AS <a 1>] <s 2> [AS <a 2>] ...
                   <agg> <sm> [AS <a m>] <agg> <s n> [AS <a n>] ...
           GROUP BY <s1> <s 2> ....
    To use the GROUP BY clause, you must specify all of the relevant columns in the SELECT clause. In the GROUP BY clause, you list the field names of the columns whose contents must be the same. You can only use the field names as they appear in the database table. Alias names from the SELECT clause are not allowed.
    All columns of the SELECT clause that are not listed in the GROUP BY clause must be included in aggregate functions. This defines how the contents of these columns is calculated when the lines are summarized.
    Specifying Columns Dynamically
    To specify the columns in the GROUP BY clause dynamically, use:
    ... GROUP BY (<itab>) ...
    where <itab> is an internal table with line type C and maximum length 72 characters containing the column names <s 1 > <s 2 > .....
    Example
    DATA: CARRID TYPE SFLIGHT-CARRID,
          MINIMUM TYPE P DECIMALS 2,
          MAXIMUM TYPE P DECIMALS 2.
    SELECT   CARRID MIN( PRICE ) MAX( PRICE )
    INTO     (CARRID, MINIMUM, MAXIMUM)
    FROM     SFLIGHT
    GROUP BY CARRID.
      WRITE: / CARRID, MINIMUM, MAXIMUM.
    ENDSELECT.
    regards
    vinod

  • Where or Having clause and COUNT(1)

    I'm having trouble trying to figure out the way to get the conditional difference between two counts in a where clause.
    I would like to scan a table and only select records where the record count of one column attribute is different than another.
    I have
    select name, count(1) from skill <<< TOTAL_COUNT
    and
    select name, count(1) from skill where score is not NULL <<<< SCORED_COUNT
    I want to have a statement that just returns the names for those where TOTAL_COUNT - SCORED_COUNT = 0
    ... meaning those names where any of the rows have not been scored.
    I've tried a "having clause" but it still returns all there names. Even those there TOTAL_COUNT - SCORED_COUNT > 0
    Here's the non-working code....
    select * from
    (select full_name
    from emp e
    where e.manager = 'Smith, John'
    having
    ((select count(1)
    from emp_skill es
    where es.emp_fk = e.id
    group by null) -
    (select count(1)
    from emp_skill es1
    where es1.emp_fk = e.id and
    es1.self_prof is not NULL
    group by null)) = 0
    )

    Don't take 3360 too seriously in this context. COUNT(expression) is a bit of a running joke around these parts.
    However, his response does contain the seed of the solution for your problem.
    COUNT(<expression>) works because the COUNT function counts all rows with a non-null value for expression. So COUNT('Chocula') counts the non-null occurences of the literal string 'Chocula' in the table. Obviously, this counts every row in the table. COUNT(*) counts all the non-null occurences of a row in the table (even a row with all null values is a row). Clearly these are equivalent.
    However, if <expression> evaluates differently for each row, then COUNT(*) and COUNT(<expression>) can differ. So, for your example, assuming that the scored column is truly NULL in some records, what you need is something like:
    SQL> SELECT * FROM skill;
    NAME            SCORE
    BOB                 5
    BOB                 6
    BOB                 7
    BILL                5
    BILL                8
    BILL
    SQL> SELECT name, total, scored
      2  FROM (SELECT name, count(*) total, count(score) scored
      3        FROM skill
      4        GROUP BY name)
      5  WHERE total <> scored;
    NAME            TOTAL     SCORED
    BILL                3          2

  • Why Scalar Subquery expression cannot be used in HAVING clauses?

    Hi All,
    I'm new to SQL. I'm confused with Scalar Subquery.
    Is there anyone who can answer me why Scalar Subquery expression cannot be used in HAVING clauses.
    Can you show me a example?
    Thanks very much,
    Xianyi.Ye
    Edited by: 908428 on 2012-1-16 下午7:24

    Hi,
    908428 wrote:
    Hi Frank,
    Thank you for your quick reply. I also agree with your point.
    But when I read the book, "OCA Oracle Database SQL Certified Expert Exam Guide",( link to illegal copies of book removed by moderator )
    on Page 359, it said that
    Scalar subquery expressions cannot be used in the following locations:
    1. In CHECK constraints
    2. In GROUP BY clauses
    3. In HAVING clauses
    4. In a function-based index (which is coming up in Chapter 11)
    5. As a DEFAULT value for a column
    6. In the RETURNING clause of any DML statement
    7. In the WHEN conditions of CASE
    8. In the START WITH and CONNECT BY clauses, which we discuss in
    Chapter 16.7 and 8 are wrong. Scalar sub-queries can be used in WHEN conditions and START WITH and CONNECT BY clauses. (At least in Oracle 10.2. Is the book based on some earlier version?)
    Edited by: BluShadow on 17-Jan-2012 09:08

  • As we are having a problem explicit with Adobe Reader 11.0.07, we are interested in news and dates for coming updates to Adobe Reader. Can I find information about this anywhere ?

    As we are having a problem explicit with Adobe Reader 11.0.07, we are interested in news and dates for coming updates to Adobe Reader. Can I find information about this anywhere ?

    Hello Claus,
    you could have a look here: http://helpx.adobe.com/security/products/flash-player/apsb14-13.html  and in german language http://www.chip.de/downloads/Adobe-Reader_12998358.html
    In all These cases Google could be "your friend".
    Hans-Günter

  • XSLT Grouping & Muenchian Method STRANGE PROBLEM

    Hi Everyone!
    I'm having a problem using a XMLTRANSFORM for grouping Muenchian Method.
    There are three oracle databases:
    DB1: Win2k3, Oracle 9.2.0.7 Standard,
    DB2: Win2k3, Oracle 9.2.0.7 Enterprise,
    DB3: WinXP, Oracle 10.2.0.1 XE.
    DB1 and DB2 are installed on different computers.
    And there are two scripts:
    S1: select
      xmltransform(xmltype(
      '<PROJECTS>
      <PROROW>
        <id>2</id><name>Customer 1</name><project_name>Project 2</project_name>
      </PROROW>
      <PROROW>
        <id>1</id><name>Customer 1</name><project_name>Project 1</project_name>
      </PROROW>
      <PROROW>
        <id>3</id><name>Customer 2</name><project_name>Project 1</project_name>
      </PROROW>
    </PROJECTS>'),
    xmltype(
    '<?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" encoding="UTF-8" version="1.0" indent="yes"></xsl:output>
    <xsl:key name="rows" match="PROROW" use="name" />
    <xsl:template match="PROJECTS">
    <xsl:element name="ROOT">
      <xsl:apply-templates
        select="PROROW[generate-id(.) = generate-id(key(''rows'', name)[1])]">
            <!--<xsl:value-of select="key(''rows'', name)">-->
      </xsl:apply-templates>
    </xsl:element>  
    </xsl:template>
    <xsl:template match="PROROW">
      <b><xsl:value-of select="name" /></b>
      <ul>
        <xsl:for-each select="key(''rows'', name)">
          <li>
            <xsl:element name="COUNT_KEYS">
              <xsl:value-of select="count(key(''rows'', name))" />
            </xsl:element>
            <a href="projects_results.xml?project={id}">
              <xsl:value-of select="project_name" />
            </a>
          </li>
        </xsl:for-each>
      </ul>
    </xsl:template>
    </xsl:stylesheet>')) x
    from dual;S2: select
      xmltransform(xmltype(
      '<REPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="report.xsd">
      <CONCEPT ID="0" TYPE="0">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">0</COL>
        </ROW>
      </CONCEPT>
      <CONCEPT ID="0" TYPE="1">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">9.93a</COL>
        </ROW>
      </CONCEPT>
      <CONCEPT ID="0" TYPE="1">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">9.94</COL>
        </ROW>
      </CONCEPT>
      <CONCEPT ID="0" TYPE="1">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">10.44</COL>
        </ROW>
      </CONCEPT>
      <CONCEPT ID="0" TYPE="1">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">10.93</COL>
        </ROW>
      </CONCEPT>
      <CONCEPT ID="0" TYPE="1">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">10.94</COL>
        </ROW>
      </CONCEPT>
    </REPORT>'),
    xmltype(
    '<?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="UTF-8" version="1.0" indent="yes"></xsl:output>
    <xsl:key name="rows" match="CONCEPT" use="concat(@ID, @TYPE)" />
    <xsl:template match="REPORT">
      <xsl:copy>
          <xsl:apply-templates select="@*"/> 
          <xsl:apply-templates
            select="CONCEPT[generate-id(.) = generate-id(key(''rows'', concat(@ID, @TYPE))[1])]"/>
      </xsl:copy>
    </xsl:template>
    <xsl:template match="CONCEPT">
      <xsl:copy>
          <xsl:apply-templates select="@*"/>
          <!--<xsl:value-of select="count(key(''rows'', concat(@ID, @TYPE)))"/>|-->
          <xsl:for-each select="key(''rows'', concat(@ID, @TYPE))">
                        <xsl:copy-of select="ROW"/>
          </xsl:for-each>
      </xsl:copy>    
    </xsl:template>
    <xsl:template match="@*">
      <xsl:copy-of select="."/>
    </xsl:template>
    </xsl:stylesheet>')) x
    from dual;S1 comes from http://sourceware.org/ml/xsl-list/2000-07/msg00458.html.
    S2 is mine.
    The results of executing these scripts are:
    S1 on DB1 & DB2:
    <ROOT>
      <b>Customer 1</b>
      <ul>
        <li>
          <COUNT_KEYS>1</COUNT_KEYS>
          <a href="projects_results.xml?project=2">Project 2</a>
        </li>
      </ul>
      <b>Customer 2</b>
      <ul>
        <li>
          <COUNT_KEYS>1</COUNT_KEYS>
          <a href="projects_results.xml?project=3">Project 1</a>
        </li>
      </ul>
    </ROOT>S2 on DB1 & DB2 is variable. For example:
    <REPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="report.xsd">
      <CONCEPT ID="0" TYPE="0">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">0</COL>
        </ROW>
      </CONCEPT>
      <CONCEPT ID="0" TYPE="1">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">9.93</COL>
        </ROW>
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">9.94</COL>
        </ROW>
      </CONCEPT>
    </REPORT>I obtained results with 2 (first two) and 5 (correct result!) <ROW> elements for <CONCEPT ID=”0” TYPE=”1”>.
    When I run S3 cyclic it returns (randomly): 2, 2, 2, 2, 5, 5, 2, 2, 2, 2, 2, 2, 2, 5, 5, 5, 5, 2, ,2, 2, 2,5, 5, 5, 5, 5, 2, 2, 2 ROWs for 2nd CONCEPT. Sounds impossible? 1st CONCEPT is always with 1 <ROW>.
    I noticed that, when I remove xsi:noNamespaceSchemaLocation="report.xsd" attribute or set it to the value of not registered schema, S2 always return one (the first from the top) ROW for both CONCEPTs.
    I don't think it is a problem of my report.xsd schema, but the content of this schema is:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:flags="291" oraxdb:schemaURL="report.xsd" oraxdb:schemaOwner="SYS" oraxdb:numProps="7">
      <xs:element name="REPORT" type="reportType" oraxdb:propNumber="2447" oraxdb:global="true" oraxdb:SQLName="REPORT" oraxdb:SQLType="reportType229_T" oraxdb:SQLSchema="SYS" oraxdb:memType="258"/>
      <xs:complexType name="reportType" oraxdb:SQLType="reportType229_T" oraxdb:SQLSchema="SYS">
        <xs:sequence>
          <xs:element maxOccurs="unbounded" name="CONCEPT" oraxdb:propNumber="2453" oraxdb:global="false" oraxdb:SQLName="CONCEPT" oraxdb:SQLType="CONCEPT230_T" oraxdb:SQLSchema="SYS" oraxdb:memType="258" oraxdb:SQLInline="true" oraxdb:MemInline="false" oraxdb:JavaInline="false" oraxdb:SQLCollType="CONCEPT236_COLL" oraxdb:SQLCollSchema="SYS">
            <xs:complexType oraxdb:SQLType="CONCEPT230_T" oraxdb:SQLSchema="SYS">
              <xs:sequence>
                <xs:element maxOccurs="unbounded" name="ROW" oraxdb:propNumber="2452" oraxdb:global="false" oraxdb:SQLName="ROW234" oraxdb:SQLType="ROW231_T" oraxdb:SQLSchema="SYS" oraxdb:memType="258" oraxdb:SQLInline="true" oraxdb:MemInline="false" oraxdb:JavaInline="false" oraxdb:SQLCollType="ROW234235_COLL" oraxdb:SQLCollSchema="SYS">
                  <xs:complexType oraxdb:SQLType="ROW231_T" oraxdb:SQLSchema="SYS">
                    <xs:sequence>
                      <xs:element maxOccurs="unbounded" name="COL" oraxdb:propNumber="2451" oraxdb:global="false" oraxdb:SQLName="COL" oraxdb:SQLType="COL232_T" oraxdb:SQLSchema="SYS" oraxdb:memType="258" oraxdb:SQLInline="true" oraxdb:MemInline="false" oraxdb:JavaInline="false" oraxdb:SQLCollType="COL233_COLL" oraxdb:SQLCollSchema="SYS">
                        <xs:complexType oraxdb:SQLType="COL232_T" oraxdb:SQLSchema="SYS">
                          <xs:simpleContent>
                            <xs:extension base="xs:string">
                              <xs:attribute name="NAME" type="xs:string" use="required" oraxdb:propNumber="2450" oraxdb:global="false" oraxdb:SQLName="NAME" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1"/>
                            </xs:extension>
                          </xs:simpleContent>
                        </xs:complexType>
                      </xs:element>
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
              <xs:attribute name="ID" type="xs:short" use="required" oraxdb:propNumber="2448" oraxdb:global="false" oraxdb:SQLName="ID" oraxdb:SQLType="NUMBER" oraxdb:memType="3" oraxdb:memByteLength="2"/>
              <xs:attribute name="TYPE" type="xs:short" use="required" oraxdb:propNumber="2449" oraxdb:global="false" oraxdb:SQLName="TYPE" oraxdb:SQLType="NUMBER" oraxdb:memType="3" oraxdb:memByteLength="2"/>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>S1 on DB3:
    <ROOT>
      <b>Customer 1</b>
      <ul>
        <li>
          <COUNT_KEYS>2</COUNT_KEYS>
          <a href="projects_results.xml?project=2">Project 2</a>
        </li>
        <li>
          <COUNT_KEYS>2</COUNT_KEYS>
          <a href="projects_results.xml?project=1">Project 1</a>
        </li>
      </ul>
      <b>Customer 2</b>
      <ul>
        <li>
          <COUNT_KEYS>1</COUNT_KEYS>
          <a href="projects_results.xml?project=3">Project 1</a>
        </li>
      </ul>
    </ROOT>S2 on DB3
    <REPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="report.xsd">
      <CONCEPT ID="0" TYPE="0">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">0</COL>
        </ROW>
      </CONCEPT>
      <CONCEPT ID="0" TYPE="1">
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">9.93a</COL>
        </ROW>
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">9.94</COL>
        </ROW>
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">10.44</COL>
        </ROW>
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">10.93</COL>
        </ROW>
        <ROW>
          <COL NAME="REG_ID">0</COL>
          <COL NAME="UNIT_ID">0</COL>
          <COL NAME="UNIT">RAPORT ZBIORCZY</COL>
          <COL NAME="LP_OPIS">10.94</COL>
        </ROW>
      </CONCEPT>
    </REPORT>DB3 always generates good results for both scripts. <CONCEPT ID=”0” TYPE=”1”> always consists of 5 ROWs regardless of the attribute xsi:noNamespaceSchemaLocation value (schema registered or not). It is my computer at home. I decided to install oracle there because of the problems with DB1 and DB2. Unfortunately these are my DBs at work. So I need to run XMLTRANSFORM there.
    IMHO problems of S2 derive from result of S1 - function count(key(''rows'', name))
    always returns 1 regardless of number of rows. But this is only my supposition.
    I don’t know what is going on. The results of S3 on DB1/2 make me sick.
    I tried client 9.2.0.8, instant client 11.1.0.6.0 and no client – a job (transformation was inserted to a table) and this problem still exists.
    Any suggestions?
    Thanks in advice…
    Tomek.

    Hi,
    maybe you are right (I think similar), but I can't find any information about this bug on the Internet. So this is strange, if it is really a bug. I hope somebody used (or tried to use) this Muenchian Method in oracle 9.2.x, and can tell does it works or not.
    In [Oracle9i XML Developers Kits|www.oracle.com/technology/tech/xml/xdk_sample/9ir2_xdkfaq.html] there is written:
    "You can do the grouping in your XSLT stylesheet Steve Muench's Book "Building Oracle XML Applications" book dedicates a section in Chapter 9 to techniques for doing this kind of grouping in XSLT to present one- or multi-level break reports...
    The technique that I present in steve's book was coined the (blush...) "Muenchian Method" for doing grouping in XSLT."
    Thanks,
    Tomek.
    Edited by: tdomanek on 2009-03-15 17:14
    Edited by: tdomanek on 2009-03-15 23:48

  • Which two statements are true about WHERE and HAVING clause ?

    Which two statements are true about WHERE and HAVING clause ?
    1. WHERE clause can be used to restict rows only
    2.HAVING clause can be used to restrict groups only
    3.HAVING clause can be used to restrict groups and rows
    Plz help me in dis ques...which two will be correct...i think its 1 and 2...but not sure.

    863180 wrote:
    Plz help me in dis ques...which two will be correct...i think its 1 and 2...but not sure.If you are not sure then you do not fully understand HAVING.
    SY.

  • Use of Where and having clause

    Hi all,
    I always have a doubt about use of HAVING and WHERE clause,
    suppose I have table T1 with only one column C1
    CREATE TABLE T1
    (C1 VARCHAR2(1) );
    which having data by following INSERT scripts
    INSERT INTO T1 VALUES('A');
    INSERT INTO T1 VALUES('B');
    INSERT INTO T1 VALUES('C');
    INSERT INTO T1 VALUES('A');
    INSERT INTO T1 VALUES('B');
    INSERT INTO T1 VALUES('A');
    Now I want result as follows
    C1 ==== COUNT(C1)
    ==============
    B ===== 2
    A ===== 3
    So out of query 1 and 2 which approach is right ?
    1) SELECT C1,COUNT(C1) FROM T1
    WHERE C1<>'C'
    GROUP BY C1
    ORDER BY C1 DESC;
    2) SELECT C1,COUNT(C1) FROM T1
    GROUP BY C1
    HAVING C1<>'C'
    ORDER BY C1 DESC;
    Edited by: user13306874 on Jun 21, 2010 2:36 AM

    In SQL, it's always best to filter data at the earliest moment possible.
    In your example the WHERE clause would be that moment:
    SQL> explain plan for
      2  select c1,count(c1)
      3  from t1
      4  where c1 != 'C'
      5  group by c1
      6* order by c1 desc;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3946799371
    | Id  | Operation          | Name | Rows  | Bytes |
    |   0 | SELECT STATEMENT   |      |     5 |    10 |
    |   1 |  SORT GROUP BY     |      |     5 |    10 |
    |*  2 |   TABLE ACCESS FULL| T1   |     5 |    10 |
    Predicate Information (identified by operation id):
       2 - filter("C1"!='C')
    18 rows selected.
    SQL>As you can see the filter is applied during the scan of T1.
    Whereas in the HAVING case:
    SQL> explain plan for
      2  select c1,count(c1)
      3  from t1
      4  group by c1
      5  having c1 != 'C'
      6* order by c1 desc;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3146800528
    | Id  | Operation           | Name | Rows  | Bytes |
    |   0 | SELECT STATEMENT    |      |     6 |    12 |
    |*  1 |  FILTER             |      |       |       |
    |   2 |   SORT GROUP BY     |      |     6 |    12 |
    |   3 |    TABLE ACCESS FULL| T1   |     6 |    12 |
    Predicate Information (identified by operation id):
       1 - filter("C1"!='C')
    18 rows selected.
    SQL>The scan is done after all groups have been computed: one of which was computed in vain, since it will be filtered away due to the HAVING clause.
    In general I would use as a guideline: if you are not using aggregate functions in your HAVING clause predicate, then move that predicate to the WHERE portion of your query.
    Edited by: Toon Koppelaars on Jun 21, 2010 11:54 AM

  • Select stmts with Having Clause

    Hi,
    Can some body help me to improve the performance of the below query...
    select t.seq_no,t.contract_id,t.date_from from test_plan_tab t
    group by t.seq_no,t.contract_id,t.date_from
    having (select count(*)
    from test_plan_tab p
    where p.contract_id = t.contract_id
    and p.date_from = t.date_from) > 1
    The having clause will reduce the performance of the above query I guess...
    Thanks And Best Regards,
    /Dinesh...

    If Seq_no is unique then try this
    SELECT MIN(t.seq_no),contract_id,t.date_from,count(*) from test_plan_tab t
    group by t.contract_id,t.date_from
    HAVING COUNT(*) > 1or
    you can try as fsitja said, but you can omit the group by as the partition has already been done on grouping columns
    SELECT seq_no, contract_id, date_from
      FROM (SELECT t.seq_no, t.contract_id, t.date_from, COUNT(*) over(PARTITION BY contract_id, date_from) tot
              FROM test_plan_tab t)
    WHERE tot > 1Regards,
    Prazy

Maybe you are looking for

  • SSO from non-SAP application to EP system

    Hi all, Is it possible to configure the Single sign-on from non-SAP application to SAP Enterprise portal? My requirement is I have a link to "Enterprise Portal" in my company's website home page. If I click on the link, it should directs to EP portal

  • HELP! Files won't open and previously had Firefox icon instead of DW icons!  Leap Year thing?

    Hi!  I went to update my website, which I do every night before the first day of every month and all the files had a FIrefox icon instead of the usual Dreamweaver one.  I have shut down, reinstalled DW MX 2004 but the files still do not open.  The ic

  • Pls Help!-'Failed to open the file'

    what do you do when an error 'failed to open the file' shows up when you try to open something...? i'm pretty sure that i am using the same version of flash as the one i used before to create this file.. but just on a different mac. please help!!!! (

  • Problems with the printer

    Hi, I have a HP PSC 1410 All-in-One printer, it's been working fine but a few days ago it just stopped printing... - i rebooted both, the mac and the printer several times - changed usb ports - bought another usb cable - and finally I followed an ass

  • EPM v11.1.2.3-suggestion needed

    Our client is using older version of Hyperion Enterprise for their financial consolidation and reporting. They are planning to implement latest version of Hyperion so we suggsted them to go for HFM v11.1.2.3 latest version. I have few questions and