What sql function can I use?

Dear all,
I have 2 sets of data and they are the followings:
Invoice No. Invoice Date Apply Date Amount
======================================
A123 01-Nov-2005 11-Nov-2005 1000
A123 01-Nov-2005 18-Nov-2005 500
Under this circumstances, for the same "Invoice No." for different "Apply Date", I want to get the minimum Apply Date. As a result, the following 2 sets of data I would like to get.
Invoice No. Invoice Date Apply Date Amount
======================================
A123 01-Nov-2005 11-Nov-2005 1000
A123 01-Nov-2005 11-Nov-2005 500
Thanks,
Amy

Try this.
select invoice_no, invoice_date,
min(invoice_date) over (partition by invoice_no) as apply_date,
amount
from your_table;

Similar Messages

  • What function can be used to give a "count of occurrences of values" ?

    I would be very appreciative if someone in the user community could save me a few months of work....I've already been neck deep in my old statistics and calculus manuals. What function can be used to get the count of occurrences of the value of an item. Ex: Item is Status and possible values are "Published", "In Production", "Construction". In one report, I want to report all records of a table and list the Status (among other items) but at the total, I would like to see a count of each value for the item Status....something like Sum(Count(Status = "Published")) Sum(Count(Status = "In Production")) Sum(Count(Status = "Construction")). I know I could run the report 3 times counting a unique value, but I'm trying to be more efficient in my reporting. Thanks all for any help given.

    Hi
    In addition to John's answer, inside Discoverer you can do this:
    Let's assume you have a Status item and it has the values you mention. If you create the following new calculation SUM(ROWNUM) and name it Status Count you only need to include the Status and the Status Count in the worksheet. You will now see a count for each status.
    Best wishes
    Michael

  • If we use DML statement in function then that function can be used inside s

    if we use DML statement in function then that function can be used inside select query or any DML query?

    select f from t2;I think you meant to query t1.
    It works if the function is an autonomous transaction:
    create or replace function f return number
    is
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
        update t1 set c=2;
        commit;
        return 1;
    end;
    select f from t1But as Billy said why would you want to do DML this way. And this is not the way autonomous procedures should be used either.
    An an answer to an interview question though nothing wrong with it.

  • What file format can be used to play 3D videos on Panasonic TVPlasma3D with USB PenDrive?

    What file format can be used to play 3D videos on Panasonic TVPlasma3D with USB PenDrive?
    I writed to Panasonic Italy support about this question:
    "What file format can be used to play 3D videos on Panasonic TVPlasma3D with USB PenDrive?"
    Panasonic writed me in a very poor manner and said me:
    "...riproduce formati: AVCHD (anche 3D), SD-Video, DivXHD, JPEG, MP3, AAC tramite USB e Slot SD/SDHC/SDXC card..."
    "...formato : AVCHD estensione file nella SD: .MTS..."
    I made a few videos edited with PremiereProCS5 and exported as H.264 Coding and .mp4 file extension, all side by side, with layout 1920x1080pixels that includes two stretched frames at 960x1080 pixels.
    This is the same image layout that uses the Panasonic 3D consumer camcorder "HDC-SDT750", that record AVCHD videos with file extension .MTS.
    I also tried to export another video as MPEG2 with .mpg file extension.
    But at the store the tests failed, and I cannot see anything!
    My questions are:
    1) What format can be used by PremiereProCS5 for exporting the Stereoscopic 3D videoclip and play them via USB port on Panasonic TVPlasma3D such "TX-P46VT20"?
    2) What codec should be used? H.264? H.264-bluray?
    3) What file extension should have the movie file? .mp4?
    Many Thanks!
    Horsepower0171.

    -I already read entirely those threads, but nothing about stereoscopic 3D AVCHD movies through USB port, on Panasonic TVPlasma3D.
    (Also, Sony said me that is not possible to play 3D videos on your 3DTV through USB port).
    I tried to made a H.264 videoclip, with .MP4 extension, at 960x1080p side-by-side layout, but nothing was displayed, and black screen.
    I think that just the AVCHD movies, with .MTS extension, that comes from Panasonic consumer camcorder "HDC-SDT750", can play the 3D videos via HDMI cable, not USB port.
    But not the exported videos from PremierePro via USB port.
    I seen this tutorial from David K Helmly:
    http://www.youtube.com/user/dhelmly#p/a/u/1/_YtF0c2bmkw
    Dave export the video from PremiereProCS5 as "MPEG2-bluray" format with "Match Source Attributes (HighQuality)" Preset, and build the Bluray Disc in EncoreCS5, with the footage as MPEG2 with .m2v file extension:
    1) Anyone tried to play correctly in 3D, those MPEG2-.m2v side-by-side files, in Panasonic3DTV, with BlurayDiscReader?
    2) Why MPEG2.m2v side-by-side?
    3) The official standard stereoscopic 3D format, is not the .MVC (MultiViewCoding) for Bluray3D Disc?
    I am confused!
    Help!
    Horsepower0171.

  • What silent switch can I use to make this uninstall? C:\Program Files (x86)\Common Files\Adobe\OOBE\PDApp\core\PDApp.exe --appletID="DWA_UI" --appletVersion="2.0" --mode="Uninstall" --mediaSignature="{A4ED5E53-7AA0-11E1-BF04-B2D4D4A5360E}"

    What silent switch can I use to make this uninstall? C:\Program Files (x86)\Common Files\Adobe\OOBE\PDApp\core\PDApp.exe --appletID="DWA_UI" --appletVersion="2.0" --mode="Uninstall" --mediaSignature="{A4ED5E53-7AA0-11E1-BF04-B2D4D4A5360E}"

    Your install log indicates you are facing file permission issues.  You can see an example here:
    DF037: Unable to delete directory "C:\Program Files\Common Files\Adobe\Keyfiles". Error 145 The directory is not empty.(Seq 1)
[    1904] Fri Dec 28 07:00:31 2012  WARN
DW063: Command ARKDeleteDirectoryCommand failed.(Seq 1)
[    1904] Fri Dec 28 07:00:31 2012 ERROR
DF037: Unable to delete directory "C:\Program Files (x86)\Common Files\Adobe\ssc\CreativeCloud-CS6-Win-GM". Error 145 The directory is not empty.(Seq 2)
[    1904] Fri Dec 28 07:00:31 2012  WARN
DW063: Command ARKDeleteDirectoryCommand failed.(Seq 2)
[    1904] Fri Dec 28 07:00:31 2012 ERROR
DF037: Unable to delete directory "C:\Program Files (x86)\Common Files\Adobe\ssc\CreativeCloud-CS6-Mac-GM". Error 145 The directory is not empty.(Seq 3)
[    1904] Fri Dec 28 07:00:31 2012  WARN
DW063: Command ARKDeleteDirectoryCommand failed.(Seq 3)
[    1904] Fri Dec 28 07:00:31 2012 ERROR
DF037: Unable to delete directory "C:\Program Files (x86)\Common Files\Adobe\ssc\AMT". Error 145 The directory is not empty.(Seq 4)
    You will want to adjust the file permissions for C:\Program Files\Common Files\Adobe and C:\Program Files(x86)\Common Files\Adobe.  You can find information on how to adjust the file permissions at Error "Exit 6" or "Exit 7" | Install log | Read, write, system file errors | CS5, CS5.5 - http://helpx.adobe.com/creative-suite/kb/error-exit-6-exit-7.html.  Please make sure you apply the permission change to all child objects.
    In general you can find information on how to review and interpret your installation log at Troubleshoot with install logs | CS5, CS5.5, CS6 - http://helpx.adobe.com/creative-suite/kb/troubleshoot-install-logs-cs5-cs5.html.

  • What video codecs can be used with Premiere CS4?

    What video codecs can be used with Premiere CS4?  Or are there to many to list?  I'm looking for a solution to import a .AVI file created with a H.264 codec.

    PrPro can work with so very many, but certainly not all. Some, like DivX will work for Export, but I have never gotten good Import of that material - always something wrong somewhere.
    For H.264, there are three very popular versions: Apple, Lead and MainConcept. The Apple version installs with later versions of QT Player, the other two are available, and many users like them better. They solve some H.264 problems, mainly with Export.
    For a bit of background, you might find this ARTICLE useful.
    Good luck,
    Hunt

  • What blueray writer can I use with my MacBook pro

    What blueray writer can I use with my MacBook Pro

    Apple Compatible Mac Webcams
    iChatUSBCam.  The manufacturer’s website also has a *free* demo of its product & a complete list of USB webcams compatible w/macs & its product.
    For more suggestions, check out EZJim’s website which can be found HERE. <--Clicky click

  • What photo gallery can I use for a Mac OS X version 10.6.8 with 1GB memory?

    what photo gallery can I use for a Mac OS X version 10.6.8 with 1GB memory?

    What do you mean by photo gallery?  Are you referring to what version of the iPhoto application?  What version came with your iMac? 
    iPhoto 8.1.2 would be a good choice for that system and limited amount of memory.  It comes on the iLife 09 disc which is available from 3rd party vendors like Amazon.com or eBay.com.
    If you can add memory to your iMac do so.  Increasing memory to 4 GB will do wonders for the speed of the system and applications. 
    OT

  • What is the largest MMC and SD card that the Acer C710 can use, and what file formats can be used?

    What is the largest MMC and SD card that the Acer C710 can read from and write to when inserted into the built-in 2-in-1 card reader? What file formats can be used with aforementioned MMC and SD cards?i.e. FAT, FAT 32, exFAT, etc.

    Thank you for you help. I forgot to mention what is the highest class of SD card it can use at top speed, and are there any classes that will simply not work? An example answer would be, the highest speed that it can operate at clase 6, with class 8 being the highest class compatible; class 10 will not work. Also note, there are new cards faster than class 10. I have seen symbols like U1 and U3. I don't expect a discount computer to run an SD card faster than class 10, but it is important to know if U1 and U3 at least work.

  • What Itunes version can i use both and ipod classic and ipod touch?

    What Itunes version can i use both and ipod classic and ipod touch?

    Hello laurie0823,
    already have ipod 32 gig and just go ipod touch 8 gig can i use both on same itunes account?
    Yes. There is no limit to the number of iPods you can have synced with one iTunes account or library.
    if i hook up ipod touch will i lose all of the stuff in library or can i sync library to ipod touch?
    No you can sync your content to any number of devices.
    Simply, plug new iPod in, configure it to sync with iTunes library however you wish and be on your way.
    For more help on different ways to manage multiple ipods with one computer, see this Apple support document.
    http://support.apple.com/kb/HT1495
    B-rock

  • I can't use Safari as my browser for an on-line training seminar. What other browser can I use and how do I get it?

    I can't use Safari as my browser for an on-line training program. What other browser can I use and how do I get it?

    Web Browsers for Mac OS X
    Pure Mac: Web Browsers
    Web Browsers for the Mac
    Download the browsers from their website.

  • What service provider can you use with iphone that you buy at Apple

    What service provider can I use with an iphone I buy at the apple store?

    Verizon, AT&T, Sprint, or T-Mobile.

  • What VGA adapter can I use with older MacPro?

    What VGA adapter can I use with older MacPro?

    One way to find this information:
     menu > About This Mac > (More Info) ...
    ... in the header on on the right side click "Overview" and cut and paste the information there, BUT remove your serial number before clicking (Save Reply) on the forums.
    _OR_
    ...on the right-hand side of the header click "Support".
    In the lower half of the window that opens click "Specifications".
    cut and paste the heading of the article that opens, such as:
    "Mac Pro (Early 2009) - Technical Specifications"

  • Slow SQL Function, can it be made to run faster?

    Hi there,
    I am using Oracle 11.1
    I have a simple OWB map that uses the transformation object calling the below function to return a value. The source table for the map contains ~17,000 records, The look-up table used below (BCGDHSC) contains ~180,000 records. My problem is the job takes 17 minutes to run with this function being called, if I comment out the look-up portion it takes about 3 seconds? Any ideas on how I can speed this up or ideas as to what I am doing wrong?
    CREATE OR REPLACE FUNCTION "F_GET_PLAN"("EMPLOYEE_ID_IN" IN VARCHAR2, "REGION_CD_IN" IN VARCHAR2) RETURN VARCHAR2 PARALLEL_ENABLE IS
    --init variable
    control_plan_out varchar2(2);
    rec_count int;
    BEGIN
    --Get the record count to see if it exists
    select count(*) into rec_count from BCGDHSC WHERE HSC_REGION_CD = REGION_CD_IN and HSC_EMPLOYEE_ID = EMPLOYEE_ID_IN and rownum=1;
    if rec_count <1 then
    return '00';
    else
    select distinct NVL(control_plan,'00') into control_plan_out from BCGDHSC WHERE HSC_REGION_CD = REGION_CD_IN and HSC_EMPLOYEE_ID = EMPLOYEE_ID_IN and rownum=1;
    end if;
    return control_plan_out;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    control_plan_out := '00'; -- exception code here
    RETURN control_plan_out;
    WHEN OTHERS THEN
    NULL;
    RETURN NULL;
    END;
    Thanks,

    This is not the fastest way, but it should be better then your current version.
    Fast would be to use plain SQL instead of PL/SQL. The select that is inside the function can be written as a subquery inside the other SELECT. if you avoid the function then you avoid many pl/sql context swichts. My version of the functions avoids only half of them since I removed one select.
    CREATE OR REPLACE FUNCTION "F_GET_PLAN"("EMPLOYEE_ID_IN" IN VARCHAR2, "REGION_CD_IN" IN VARCHAR2)
      RETURN VARCHAR2 PARALLEL_ENABLE IS
    --init variable
      control_plan_out varchar2(2);
      rec_count int;
    BEGIN
    select NVL(control_plan,'00')
    into control_plan_out
    from BCGDHSC
    WHERE HSC_REGION_CD = REGION_CD_IN  /*  number or string comparsion here ? */
    and HSC_EMPLOYEE_ID = EMPLOYEE_ID_IN /*  number or string comparsion here ? */
    and rownum=1;
    return control_plan_out;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
      -- this already takes care of the count = 0 logic
      control_plan_out := '00'; -- exception code here
      RETURN control_plan_out;
    END;Also I note that all your "IDs" are strings. Is this intended ? if not you might want to change them into proper number data types.

  • SQL Developer can be used for database design

    can I use SQL Developer to design the database?

    It really depends on what you mean by "can," how complex the schema design is going to be, and your comfort level.
    AB is quite right to point out Oracle Designer-- that's a very powerful, very visual tool for creating physical and logical schema designs. It also has a relatively steep learning curve and a relatively large installation footprint. If you need to generate highly complex schema designs, to allow multiple modelers to work together, and you will use the tool frequently enough to justify the training time, Designer is a wonderful tool.
    On the other end of the spectrum, however, it's perfectly possible to generate a schema design using SQL*Plus or SQL Developer with a white board or scratch paper nearby to help think through various issues. The tools aren't presenting you with pretty ERDs, they're not automatically translating visual representations of designs to physical implementations, etc. but it's quite possible for a human using those tools to do the translation.
    Either way will work-- the constraints of your particular project and your comfort level with various risks will determine which approach is more appropriate.
    Justin

Maybe you are looking for

  • Issue in PO Status

    Hi There is an issue with a Service PO.When I created a service p.o the p.o value was 1,543,695.60 USD . I created service entry sheet and GR for 1,029,130.40 USD. The still to be delivered amount should be 1,543,695.60-1,029,130.40 =514565.20 USD Bu

  • Substitution : Payment block (bseg-zlspr)

    Hi, I would like to substitute the payment block when posting document header (tcode:FBR2). However, I cant find the BSEG-ZLSPR field to be substitute in the substitutable fields (tcode:ggb1 Financial Accounting > Document Header > Substitution > Ste

  • Assembly, component and operation scrap

    Dear All, I haven't got experience in SAP, that's why I'd like to ask for your help in this issue. Could you highlight/explain how these work? (effects on MRP run + behaviour when booking against PrdOrd; e.g. when I book against PrdOrd what will be t

  • Does changing server names in an XI environment  have any impact?

    Hi experts, can anyone answer the query below ? what is the impact of changing server names in an XI environment ( what exchange profile parameters need to be changed if any ) what are the risks, what may or may not stop working - can you alias to th

  • Change event to different calendar?

    Hi all, As far as I can see, there's no way to do this, but I thought I'd ask here before giving up. Can I change an event from one calendar to another directly on the iPhone? (I know I can do it in iCal.) I see I can select which calendar when creat