Need help with SQL for selecting ID where the sequence does not match..

I have the following dilemma:
Database contains IDs as follows:
Incident#, Case#, & Part Sequence#
example
Record 1
Incident_Number = 123456
Case_Number = 1
Part_sequence = 1
Record 2
Incident_Number = 123456
Case_Number = 1
Part_sequence = 2
Sometimes the user will delete (let's say) Record 2 after creating a new Record 3
So now the sequencing goes as follows:
Record 1
Incident_Number = 123456
Case_Number = 1
Part_sequence = 1
Record 2
Incident_Number = 123456
Case_Number = 1
Part_sequence = 3
Now there will no longer be a Part_Sequence 2
Need a SQL to select all records where the maximum part sequence > than the count of Incident_number||'-'||Case_number
I tried the following:
select a.incident_number||'-'||a.case_number||'-'||a.part_sequence
from chsuser.a_compl_summary a
where a.entry_date >= '01-may-2011'
and max(a.part_sequence) > count(distinct a.incident_number||'-'||a.case_number)I end up getting a ORA-00934: group function is not allowed here (highlighting on the Max(a.part_sequence) portion.
Any suggestions/hints
Thanks

select  incident_number || '-' || case_number || '-' || part_sequence
  from  (
         select  incident_number,
                 case_number,
                 part_sequence,
                 max(part_sequence) over(partition by incident_number,case_number) max_seq,
                 count(*) over(partition by incident_number,case_number) cnt
           from  chsuser.a_compl_summary
           where entry_date >= DATE '2011-05-01'
  where cnt != max_seq
/SY.

Similar Messages

  • Need help with SQL for Pie Chart

    I am trying to create a pie charge which would have 3 slices.
    Following sql gives me the expected values when I run the sql command:
    select
    round(avg(CATEGORY_1 + CATEGORY_2 + CATEGORY_3 + CATEGORY_4 + CATEGORY_5),0) "OD Engagements",
    round(avg(CATEGORY_6 + CATEGORY_7 + CATEGORY_13),0) "Talent Engagements",
    round(avg(CATEGORY_8 + CATEGORY_9 + CATEGORY_10 + CATEGORY_11 + CATEGORY_12),0) "Other Engagements"
    from OTD_PROJECT
    where STATUS in ('Open','Hold')
    I get 3 columns labeled: OD Engagements, Talent Engagements and Other Engagements with the correct averages based on the the data.
    I have tried several ways to try to get this to work in the SQL for a pie chart, but keep getting the invalid sql message and it won't save. I also tried saving without validation, but no data is shown on the chart at all.
    I want to have a pie, with 3 slices, one labeled OD Engagements with a value of 27, one labeled Talent Engagements with a value of 43 and one labeled Other Engagements with a value of 30. Then I want to be able to click on each pie slice to drill down to a secondary pie chart that shows the breakdown based on the categories included in that type.
    Since I am not grouping based on an existing field I an unsure what the link and label values should be in the chart sql.

    You'll need something like the below. I have no idea what the URL for the drilldown needs to be. It should create an appropriate link in your app for the particular slice. Mainly the code below breaks the SQL results into three rows rather than three columns. It may well have a syntax error since I can't test.
    select linkval  AS LINK,
           title    AS LABEL,
           calc_val AS VALUE
    FROM   (SELECT 'OD Engagements' AS title,
                   round(avg(CATEGORY_1 + CATEGORY_2 + CATEGORY_3 + CATEGORY_4 + CATEGORY_5),0) AS calc_val,
                   'f?p=???:???:' || v('APP_SESSION') || '::NO:?' AS LINKVAL
            from   OTD_PROJECT
            where  STATUS in ('Open','Hold')
            UNION ALL
            SELECT 'Talent Engagements' AS title,
                   round(avg(CATEGORY_6 + CATEGORY_7 + CATEGORY_13),0) AS calc_val,
                   'f?p=???:???:' || v('APP_SESSION') || '::NO:?' AS LINKVAL
            from   OTD_PROJECT
            where  STATUS in ('Open','Hold')
            UNION ALL
            SELECT 'Other Engagements' AS title,
                   round(avg(CATEGORY_8 + CATEGORY_9 + CATEGORY_10 + CATEGORY_11 + CATEGORY_12),0) AS calc_val,
                   'f?p=???:???:' || v('APP_SESSION') || '::NO:?' AS LINKVAL
            from   OTD_PROJECT
            where  STATUS in ('Open','Hold')
           );

  • The sequence does not match with the original clip

    What I have learned about how to effectively match the sequence with original clip is by dragging the imported clip into the new item button, or right click the clip and click on "New Sequence from Clip" button. I did it exactly, however, like you can see in the image I attached, there is a black space under the clip on the sequence and the general quality of video and audio are worse than the original. Why is this happening? Please help.

    Is this what you are asking about?

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • I need help with changing my verizon vm to the system voicemail

    I need help with changing my verizon vm to the system voicemail

    Deleting the iTunes account is not the solution as you will very likely lose any and all purchases ever made with the account.
    If you cannot find the option on the site, contact iTunes support.

  • I have paid for the Mountain Lion. But for some reason, I cannot seem to download it, despite software being upgraded. Anyone facing this problem where the download does not begin? How can I solve this?

    I have paid for the Mountain Lion. But for some reason, I cannot seem to download it, despite software being upgraded. Anyone facing this problem where the download does not begin? How can I solve this?

    Make sure your Mac qualifies to run Mountain Lion >  Apple - Upgrade your Mac to OS X Mountain Lion.
    Try disabling anti virus software and turn off the Firewall in System Preferencs > Security & Privacy
    Apps such as Little Snitch and Net Nanny can prevent apps from downloading from the App store including Mountain Lion.
    Third party download managers are not compatible with the App Store.
    Keep in mind, for downloading Mountain Lion from the App Store, a high speed (broadband) internet connection is strongly recommended by Apple as noted here > iTUNES STORE - MAC APP STORE - TERMS AND CONDITIONS
    If you need to reinstall OS X or repair the the startup disk using Mountain Lion Recovery, that requires broadband access to the internet via Wi-Fi or an Ethernet connection. OS X is downloaded over the internet form Apple when OS X Recovery is used for reinstallation.

  • Setup for testing server "the prefix does not match.."

    I am just getting started using Adobe Dreamweaver CS3
    with AppServ (Apache, Php, MySQL).
    Im using Windows XP Service Pack 2 and and test it on the
    same computer.(localhost)
    I created a folder on my hard drive
    C:\AppServ\www\MyLocalSite.
    Here´s the setup under the Advanced tab in Dreamweaver:
    Server model:
    php Mysql
    Acess:
    local network
    Testing server folder:
    AppServ/www
    URL Prefix:
    http://localhost/MyLocalSite
    When I click OK, the following message is displayed:
    The site URL Prefix for the testing server does not
    match..
    I have run a lot of sites on my localhost but never ever
    get this unusual message.
    The worst is - I cant use the Recordset with Bindings in
    Dreamweaver CS3 if I dont solve this weird "prefix" problem.
    I ´ve tried a lot of workaround solutions but always end
    up with the message
    that prompt "the prefix does not match.."
    Is it a bug or what?
    I appreciate every answer
    Update
    21:47.................................................................................... .
    I´ve tried to configure a connection to the database
    and I end up with this message:
    1) There is no testing server running on the server machine
    2) The testing server specified for this site does not map
    the
    http://localhost:80/myLocalSite/_mmServerScripts/MMHTTPDB.php
    URL.
    Verify that the Prefix maps to the root of the site
    The server is running and is working when I request my local
    site in IE 7:
    localhost/myLocalSite/index.php

    I too had been experiencing this problem after installing XP
    service pack 3 last week.
    Too fix this issue I had re-assign all file permissions to my
    root web folder.
    Remove all permissions and re-assign the groups
    administrators, authenticated users and everyone FULL CONTROL of
    this folder.
    Click the advanced button and make sure permissions are not
    being inherited from the parent folder.
    Then select the option to re-assign all permissions to all
    child files/folders.
    Good luck.

  • I have an ipad, when I watch a video the audio does not match up with the video, how can I fix this?

    I have an ipad and when I watch a video the audio does not match up with the video, how can I fix this?

    Hello there, graciecloyd.
    The following Knowledge Base article offers a few steps to try when an application is not functioning as expected:
    iOS: Understanding multitasking
    http://support.apple.com/kb/ht4211
    If an app doesn't respond to your input, or doesn't perform as expected, do the following, testing after each step:
    Check for app updates.
    Force the app to close.
    Restart your device.
    Update your iOS device.
    Learn more about troubleshooting apps.
    On Step 2, close all applicaitons that are open. On Step 3, if the restart doesn't help resolve the issue, you may also want to try the Reset step in that article as well.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • When uploading my formatted resume to my Apple Jobs profile, I am always presented with a c:\fakepath message and the resume does not upload. How can I rectify this?

    When uploading my formatted resume to my Apple Jobs profile, I am always presented with a c:\fakepath message and the resume does not upload. How can I rectify this?

    Add this one to the list of thinks that don't work on the Apple Job Board. It looks like Apple is using ADP's VE (Virtual Edge) technology to run this system, and I've been stupified by the number of features that are just broken, or so poorly thought out by ADP as to be unusable, (certainly for webkit and mozilla browsers at least: I didn't bother checking IE.)
    Here are a few highlights:
    "My Job List", list of jobs applied for, seems to max out at three. You can apply for more than that, but you can only see the first three.
    "Search Using Your Resume" feature yields few or no results, even when the pasted text contains only common, exactly matched words like 'Design' or 'Engineer'.
    The missing resume upload, described in this thread.
    "My Job Agent" seems to never flag anything, at least it hasn't ever for me despite pretty loose criteria.
    Agent's created using "My Job Agent" eventually just disappear, which is fine because they don't seem to work.
    When updating a profile, acknowledging the 'Terms' happens twice in a row. 
    Job seekers can only supply one cover letter despite being able apply for several jobs.
    Pagination for search results only appears at the top of the page, so it's necessary to scroll down through each page, then up to the top again to proceed to the next page.
    Well, I'm sure there are others, but you get the idea. I hope the Apple folks can fix this, (or twist ADP's arm to fix it,) so it better represents the quality of experience that Apple is so respected for consistently delivering.

  • I was running KeyPassFox with Firefox 8.0.1, but the plugin does not work in the new release (9) . Is there a way to restore my previous version with all of my bookmarks intact? I do not mind if I have to restore the plugins myself.

    I was running KeyPassFox with Firefox 8.0.1, but the plugin does not work in the new release (9) . Is there a way to restore my previous version with all of my bookmarks intact? I do not mind if I have to restore the plugins myself.
    The plugin shows on the list as enabled and functioning, yet the tool does not show on the toolbar. It would appear that I need to restore the previous version of Firefox and wait until a newer release of the plugin is available before upgrading the browser.

    I copied the iTunes file from the external drive and it's in both places.  I thought all I would need is the iTunes program (which I downloaded to new computer) and my iTunes library file.  There must be something else that's missing.  My iTunes library looks the same on the new computer as it does when I open it on the external drive.  If I click on an iTunes library song from my new computer, it will only play if I have the external drive plugged in.
    My back-up drive is a mess.  I have multiple copies of music, video, photo, and document files and I don't know how that happened. ={  Obviously, I don't know how to back up stuff properly and there are back-up files extending over a 6- to 8-year period.  I think all I did was just drag and drop the main folders from the back-up drive to the same main folders on the C: drive.  Also (and I'm kind of fuzzy on this) Windows used to automatically save music files in a folder within my document files (which makes no sense to me).  As my Jewish friends would say, "Oy Vey!" 

  • I cannot log into facebook. I get the following message: 404 Error - Not Found The resource you have requested could not be found on the server. There are many possible reasons for this. Either the file does not exist, there is an error in your request,

    I am not able to go to the facebook site. www.facebook.com is not working. I get the following error message. 404 Error - Not Found
    The resource you have requested could not be found on the server. There are many possible reasons for this. Either the file does not exist, there is an error in your request, or the file is not accessible in the requested directory. Please verify that:
    * You have used the proper case; requests ARE case-sensitive!
    * You have entered the URL correctly. (i.e. proper directory/filename)
    * You used the FULL URL. (i.e. proper file type: .html, .gif , .jpg, etc.)
    * You use a tilde (~) before user directories. (i.e. www.furcen.org/~jurann/ )
    * The user/file still exists on this server.
    I also get redirected to "Busca Google" when typing www.facebook.com in the address bar.
    == URL of affected sites ==
    http://facebook.com; buscagoogle.com

    I have the same problem and it does not have to do with firefox. Do you have any idea how to fix it through?

  • I'm trying to make a purchase and I get a message that the information does not match with the bank. What can I do?

    I'm trying to make a purchase and I get a message that the information does not match with the bank. What can I do?

    Go to the APP store or Itunes. On the bottom of the mainpage, tap your apple id, view account. Then you can edit the payment information. Or you can do it(if you encounter a problem there) on Itunes on computer. Just go to the store, select your name and edit information. Make sure everything matches...exp date, name as appears on card etc..

  • I have a macbook pro. i have a photosmart 7510. we just bought a new windows tower and the printer works wireless for us, but now the mac does not print anymore wirelessly. i keep getting a message Network host 'HPE93F2A.local.' is busy. what can i do to

    I have a macbook pro. i have a photosmart 7510. we just bought a new windows tower and the printer works wireless for us, but now the mac does not print anymore wirelessly. i keep getting a message Network host 'HPE93F2A.local.' is busy. what can i do to

    it is a windows 8

  • In AE CS6, the sound does not match with video

    Hi,
    I would like to ask a question. I have AE CS6, and I recorded a gameplay video with Avermedia Live Gamer HD. The format of this video is .mp4. When I import the .mp4 into the program, the sound does not match. On the original video, when i play with VLC or WMP, all things are good, and when i import, the sound does not good. What causes this problem, and can I do something to solve this?
    Thanks the answers, R3dLinE

    Check your footage interpretation, split the audio in an external program, convert the sample rate and import it separately or whatever. Most likely you simply have used unsuitable recording settings with odd sample and data rates.
    Mylenium

  • Been using an Avastor HDX-800 for storage and backup, also a SUPERDISK for smaller stuff; recently the SUPERDISK does not appear on the screen, and the light blinks while you hear it spin, also the Avastor has started to have the same problem, both USB

    Been using an Avastor HDX-800 for storage and backup, also a SUPERDISK for smaller stuff; recently the SUPERDISK does not appear on the screen, and the light blinks while you hear it spin, also the Avastor has started to have the same problem, both USB conncected, both worked well before, but both now spinning, blinking, and not showing up on the screen as before,
    Interestingly they both appear in the System Profiler, but just not working the same as before
    I have tried other USB ports, but the same responce,

    yes I did reset the PRAM, but no benefit, still the same problem
    my usb devices are:  keyboard, mouse, printer, SD-USB-M3, and LaCie d2 DVDRW:
    the mouse and printed are plugged into the keyboard: i have tried to move, these around, and have even tried just the mouse, printer and SD-USB-M3, but still the same problem
    here is a cut and paste of the current  "System Profiler>Hardware>USB"   (usb device tree)
    USB Bus:
      Host Controller Location:          Built In USB
      Host Controller Driver:          AppleUSBOHCI
      PCI Device ID:          0x0026
      PCI Revision ID:          0x0000
      PCI Vendor ID:          0x106b
      Bus Number:          0x18
    Hub in Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x1002
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    HL-1270N series:
      Version:          1.00
      Bus Power (mA):          100
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Brother
      Product ID:          0x0008
      Serial Number:          L9J286292
      Vendor ID:          0x04f9
    Basic Optical Mouse:
      Version:          0.00
      Bus Power (mA):          100
      Speed:          Up to 1.5 Mb/sec
      Manufacturer:          Microsoft
      Product ID:          0x0084
      Vendor ID:          0x045e
    Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          250
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x0204
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    SuperDisk USB 120MB drive:
      Version:          0.0e
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Imation
      Product ID:          0x0002
      Vendor ID:          0x0718
    Hub in Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x1002
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    HL-1270N series:
      Version:          1.00
      Bus Power (mA):          100
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Brother
      Product ID:          0x0008
      Serial Number:          L9J286292
      Vendor ID:          0x04f9
    Basic Optical Mouse:
      Version:          0.00
      Bus Power (mA):          100
      Speed:          Up to 1.5 Mb/sec
      Manufacturer:          Microsoft
      Product ID:          0x0084
      Vendor ID:          0x045e
    Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          250
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x0204
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    HL-1270N series:
      Version:          1.00
      Bus Power (mA):          100
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Brother
      Product ID:          0x0008
      Serial Number:          L9J286292
      Vendor ID:          0x04f9
    Basic Optical Mouse:
      Version:          0.00
      Bus Power (mA):          100
      Speed:          Up to 1.5 Mb/sec
      Manufacturer:          Microsoft
      Product ID:          0x0084
      Vendor ID:          0x045e
    Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          250
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x0204
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    SuperDisk USB 120MB drive:
      Version:          0.0e
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Imation
      Product ID:          0x0002
      Vendor ID:          0x0718
    USB Bus:
      Host Controller Location:          Built In USB
      Host Controller Driver:          AppleUSBOHCI
      PCI Device ID:          0x0026
      PCI Revision ID:          0x0000
      PCI Vendor ID:          0x106b
      Bus Number:          0x19
    LaCie d2 DVDRW USB:
      Capacity:          451.76 MB
      Removable Media:          Yes
      Detachable Drive:          Yes
      BSD Name:          disk2
      Version:          0.00
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          LaCie
      OS9 Drivers:          No
      Product ID:          0x1011
      Serial Number:          FFFFFFFFFFFF
      S.M.A.R.T. status:          Not Supported
      Vendor ID:          0x059f
    LaCie d2 DVDRW USB:
      Capacity:          451.76 MB
      Removable Media:          Yes
      Detachable Drive:          Yes
      BSD Name:          disk2
      Version:          0.00
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          LaCie
      OS9 Drivers:          No
      Product ID:          0x1011
      Serial Number:          FFFFFFFFFFFF
      S.M.A.R.T. status:          Not Supported
      Vendor ID:          0x059f

Maybe you are looking for