using the max function

I'm trying to shoot 1 row for each document_id, it should be the max version, but im getting lines in double for some reason any.

----------
create the table max_test

(
'PROJECT' VARCHAR2 (50 BYTE),
"DOCUMENT_ID" VARCHAR2 (50 BYTE),
VARCHAR2 (5 BYTE) 'VERSION',
"CREATE_DATE' VARCHAR2 (DATE),
VARCHAR2 (DATE) 'UPDATE_DATE ',.
VARCAHR2 (100 BYTE) "MANAGER_NAME".

)


--------------

INSERT ALL
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 500,1, 18, March 1, 12 ', March 1, 12 ', ' BOB JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 500,2, 6, March 1, 12 ', March 1, 12 ', ' STEVE JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 500,3, 2, March 1, 12 ', March 1, 12 ', ' MIKE JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 501,4, 5, March 1, 12 ', March 1, 12 ', ' MARK JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 501,5, 1, March 1, 12 ', March 1, 12 ', ' TOM JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 502,6, 20, March 1, 12 ', March 1, 12 ', ' EVE JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 502,7, 3, March 1, 12 ', March 1, 12 ', "CHRIS JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 503,8, 1, March 1, 12 ', March 1, 12 ', ' LARRY JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 503,9, 2, March 1, 12 ', March 1, 12 ', ' JOE JONES)
;



Select distinct (project), max (version), document_id update_date, create_date, manager_name
of max_test
Project group, document_id, create_date, update_date, manager_name


I get several lines for each project and want to only 1 row by project, 1 line which is the max version

And continuing my previous post, if you want to have lines only for the maybe max version that you want to write a query like this:

SELECT project, version, document_id, create_date
     , update_date, manager_name
  FROM max_test
 WHERE (project, version) IN (  SELECT project, MAX (version)
                                  FROM max_test
                              GROUP BY project);

PROJECT  VERSION DOCUMENT_ID  CREATE_DATE UPDATE_DATE MANAGER_NAME
-------- ------- ------------ ----------- ----------- -------------
500      6       2            01-MAR-12   01-MAR-12   STEVE JONES
501      5       4            01-MAR-12   01-MAR-12   MARK JONES
502      3       7            01-MAR-12   01-MAR-12   CHRIS JONES
503      2       9            01-MAR-12   01-MAR-12   JOE JONES    

4 rows selected.

Kind regards.
Al

Tags: Database

Similar Questions

  • Oracle: how to use the max() function in expression box

    How to use the max() function in the case where expression, please explain with an example

    Hope this helps and should be explicit

    with t as
    (select 1 col,100 col2 from dual union
    select 2 ,100 from dual union
    select 2 ,200 from dual union
    select 3,100  from dual union
    select 3,200  from dual  )
    select col, case when max(col2)=100 then 'with 100 range'
    when  max(col2)=200 then 'with 200 range' end  from t group by col
    
  • SQL query using the MAX function

    I am trying to display only those records where the "date_entered" is the most recent by case number.

    SELECT distinct c.case_number, u.email,c.assigneddate_chart,
    --m.date_entered,
    max(m.date_entered)as last_date_entered,
    trunc(sysdate)-trunc(c.assigneddate_chart)days_late,
    trunc(sysdate)-trunc(m.date_entered)addl_days_late
    from chart c, chart_user_roles u,comments m
    where 
    (c.case_status IN ('Open','Pending')) and 
    c.case_number=m.case_number
    group by c.case_number, 
    u.email,c.assigneddate_chart,m.date_entered
    Right now, it's the output im get.

    Output:
    CASE_NUMBER---EMAIL---ASSIGNEDDATE_CHART---LAST_DATE_ENTERED---DAYS_LATE--ADDL_DAYS_LATE
    [email protected]
    [email protected]
    [email protected]
    [email protected]
    [email protected]
    [email protected]


    I am wanting to achieve this result:

    Therefore, based on the data below, are the only records I am wanting to display:
    [email protected]
    [email protected]


    Thank you
    Deanna
    SELECT  case_number,
            email,
            assigneddate_chart,
            date_entered,
            trunc(sysdate)-trunc(assigneddate_chart) days_late,
            trunc(sysdate)-trunc(date_entered) addl_days_late
      FROM  (
             SELECT  c.case_number,
                     u.email,
                     c.assigneddate_chart,
                     m.date_entered,
                     dense_rank() over(partition by c.case_number order by m.date_entered DESC) rnk
               FROM  chart c,
                     chart_user_roles u,
                     comments m
               WHERE c.case_status IN ('Open','Pending')
                 AND c.case_number=m.case_number
            )
      WHERE rnk = 1
    /
    

    SY.

  • the window on my computer does not return to its original size and I can't use the max and min and exit button

    my window is too far to the right and ive tried to get to the original size and it will until a certain point to the left. This leaves me unable to use the max and min and exit tabs

    Hello

    1. What is the brand and model of the computer?

    2. is it a laptop or a desktop computer?

    3. the problem occurs after leaving the game or program?

    4 did you a recent software or changes to the material on the computer?

    Method 1:

    If this happens when you leave a game, I suggest you to follow the steps mentioned in the link and check.

    Open the troubleshooter of display quality

    http://Windows.Microsoft.com/en-us/Windows7/open-the-display-quality-Troubleshooter

    Method 2:

    I also suggest you go through the steps mentioned in the link and the Coachman.

    Change your screen resolution

    http://Windows.Microsoft.com/en-us/Windows7/change-your-screen-resolution

    Method 3:

    Step 1:

    I also suggest you to check if the problem persists in safe mode.

    Start your computer in safe mode

    http://Windows.Microsoft.com/en-us/Windows7/start-your-computer-in-safe-mode

    Step 2:

    You can also check if the problem persists in a clean boot state.

    Clean boot:

    This could happen if one of the substantive programmes is in conflict with the proper functioning of your computer. To help resolve the error and other messages, you can start Windows 7 by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or Windows 7 http://support.microsoft.com/kb/929135

    Note: when you are finished troubleshooting, follow step 7 article to start the computer to a normal startup.

    Hope this helps and keep us posted.

  • SQL using the analytic function


    Hi all

    I want a help in the creation of my SQL query to retrieve the data described below:

    I have a test of sample table containing data as below:

    State ID Desc

    MICHAEL 1 T1

    ACTIVE 2 T2

    T3 3 SUCCESS

    DISABLE THE T4 4

    The thing I want to do is to select all the lines with an ACTIVE status in the table but is there is no ACTIVE status, my request will give me the last line with MICHAEL status.

    I can do this in a single request by using the analytical function for example, if yes can yiu help me on the request of unpacking.

    Kind regards

    Raluce

    Something like that?

    I had to fix it.

    with testdata until)
    Select 1 id, "T1" dsc "DISABLED" status of Union double all the
    Select 2 id, 'T2' dsc, the status "ACTIVE" of all the double union
    Select id 3, "T3" dsc, the status of 'SUCCESS' of all the double union
    Select 4 id, "T4" dsc "DISABLED" status of double
    )

    Select
    ID
    dsc
    status
    of testdata
    where
    status =
    -case when (select count (*) in testdata where status = 'ACTIVE') > 0
    then 'ACTIVE '.
    Another 'DISABLED '.
    end
    and)
    ID in (select id from testdata where status = ' ACTIVE')
    or
    ID = (select max (id) in testdata when status = 'DISABLED')
    )

    STATE ID DSC

    '2' 'T2' 'ACTIVE '.

    Maybe it's more efficient

    Select
    ID
    dsc
    status
    of testdata
    where
    status =
    -case when (select count (*) in testdata where status = 'ACTIVE') > 0
    then 'ACTIVE '.
    Another 'DISABLED '.
    end
    and
    ID =)
    -case when (select count (*) in testdata where status = 'ACTIVE') > 0
    then id
    on the other
    (select max (id) in testdata when status = 'DISABLED')
    end
    )

    Post edited by: correction of chris227

    Post edited by: chris227
    extended

  • help in the application without using the pivot function

    Hi gurus,

    Can you please help write the query without using the PIVOT function.
     WITH indata AS
             (SELECT 1 sn, '123:456,789,323:456,213,344,345:5454' x
                from dual
              UNION ALL
              SELECT 2, 'abcd:fgrfr,rfrf,rfred,tg:tg,tg:ophhh,op,vdfgbh:poijn' x from dual),
            instr AS
             (SELECT a.SN,
                     rownum RN,
                     B.column_value || CASE
                       WHEN B.column_value NOT LIKE '%:%' THEN
                        ':'
                     END column_value 
                FROM indata a,
                     TABLE(CAST(multiset
                                (SELECT trim(SUBSTR(x,
                                                    (CASE LEVEL
                                                      WHEN 1 THEN
                                                       1
                                                      ELSE
                                                       instr(x, ',', 1, LEVEL - 1) + 1
                                                    END),
                                                    (CASE instr(x, ',', 1, LEVEL)
                                                      WHEN 0 then
                                                       4000
                                                      ELSE
                                                       instr(x, ',', 1, LEVEL) - 1 -
                                                       (CASE LEVEL
                                                          WHEN 1 THEN
                                                           0
                                                          ELSE
                                                           instr(x,
                                                                 ',',
                                                                 1,
                                                                 level - 1)
                                                        END)
                                                    END)))
                                   FROM dual
                                 CONNECT BY level <=
                                            LENGTH(x) -
                                            LENGTH(REPLACE(x, ',', '')) + 1) AS
                                sys.odcivarchar2list)) b)
            SELECT  col1_val2,
                    col1_val1,
                    col2_val2,
                    col2_val1,              
                   systimestamp
              FROM (select SN,
                          ROW_NUMBER() over(partition by SN order by RN) RN,
                           SUBSTR(column_value, INSTR(column_value, ':') + 1) VAL1,
                           substr(column_value, 1, instr(column_value, ':') - 1) val2
                      FROM instr ) PIVOT(MAX(VAL1) VAL1, MAX(VAL2) VAL2 FOR SN IN(1 as col1,2 as col2));
    Thanks in advance!...

    Any help would be appreciated.

    user590978 wrote:

    Can you please help write the query without using the PIVOT function.

    with indata as (
                    select 1 sn,'123:456,789,323:456,213,344,345:5454' x from dual union all
                    select 2, 'abcd:fgrfr,rfrf,rfred,tg:tg,tg:ophhh,op,vdfgbh:poijn' x from dual
                   ),
             t1 as (
                    select  x
                      from  indata
                      where sn = 1
                   ),
             t2 as (
                    select  x
                      from  indata
                      where sn = 2
                   ),
             t3 as (
                    select  level lvl,
                            substr(
                                   x,
                                   instr(',' || x,',',1,level),
                                   instr(x || ',',',',1,level) - instr(',' || x,',',1,level)
                                  ) col1
                      from  t1
                      connect by level <= length(x) - length(translate(x,'A,','A')) + 1
                   ),
             t4 as (
                    select  level lvl,
                            substr(
                                   x,
                                   instr(',' || x,',',1,level),
                                   instr(x || ',',',',1,level) - instr(',' || x,',',1,level)
                                  ) col2
                      from  t2
                      connect by level <= length(x) - length(translate(x,'A,','A')) + 1
                   ),
             t5 as (
                    select  lvl,
                            substr(col1,1,instr(col1 || ':',':') - 1) col1_val1,
                            substr(col1,instr(col1 || ':',':') + 1) col1_val2
                      from  t3
                   ),
             t6 as (
                    select  lvl,
                            substr(col2,1,instr(col2 || ':',':') - 1) col2_val1,
                            substr(col2,instr(col2 || ':',':') + 1) col2_val2
                      from  t4
                   )
    select  col1_val1,
            col1_val2,
            col2_val1,
            col2_val2,
            systimestamp
      from      t5
            full join
                t6
            on (
                t6.lvl = t5.lvl
               )
      order by coalesce(t5.lvl,t6.lvl)
    /
    
    COL1_VAL1  COL1_VAL2  COL2_VAL1  COL2_VAL2  SYSTIMESTAMP
    ---------- ---------- ---------- ---------- -------------------------------------
    123        456        abcd       fgrfr      23-OCT-12 11.50.12.015000 AM -04:00
    789                   rfrf                  23-OCT-12 11.50.12.015000 AM -04:00
    323        456        rfred                 23-OCT-12 11.50.12.015000 AM -04:00
    213                   tg         tg         23-OCT-12 11.50.12.015000 AM -04:00
    344                   tg         ophhh      23-OCT-12 11.50.12.015000 AM -04:00
    345        5454       op                    23-OCT-12 11.50.12.015000 AM -04:00
                          vdfgbh     poijn      23-OCT-12 11.50.12.015000 AM -04:00
    
    7 rows selected.
    
    SQL> 
    

    SY.

  • How doi send texts using the speech function without hitting the Send button?

    using the speech function in texting, how to send the text without actually pushing the Send button? When I say 'send' or 'send message' he just keeps typing

    "Hey, Siri, send a message to Bob. Siri will then ask you what you want text Bob. Once you stop dictating, Siri will ask then if you're ready to send the message. Say, "Yes." It's really very nice.

    If you are already in the message app and using speech-to-text, you must press the Send button.

  • Cannot use the Val function in a script use

    I'm trying to convert a text string (binary number) in a number by using the Val function in a script of use but the colors of tiara the term Val in red and the script produces an error indicating "Variable is undefined:"Val"

    Why is that happen? Some functions are not allowed in use scripts?

    In addition, it seems impossible to use debugging in my use - if I try to add a variable to the Watch window, there never have any value even if I put a breakpoint on this line of code. Would it not possible to debug scripts use?

    David,

    regarding your question on "Val" I would like to direct you to the "File.Formatter.ParseString" function which is part of the API available at DataPlugins.

    CDbl and CLng do a good job in general, but they are dependent on the local configuration of the PC. 'ParseString' is so much more reliable.

    Andreas

  • How to connect the parallel test using the logarithmic function Teststand database result

    Hello

    How can I connect a test result of 4 EHR tested in parallel using the logarithmic function Teststand database

    I use Labview 2013, 2013 Teststand and sequential model.

    The test is performed using a single digital card (SMU-6556). The FSD 4 is connected to the port of the digital map and is tested in parallel.

    Currently at the end of the test, I would have a report with all the measures, but I need 4 reports (1 report / dut)

    TKS


  • When I use the library function node call in real time, is loaded only once for all or load the DLL whenever it is called?

    When I use the library function node call in real time, is loaded only once for all or load the DLL every time when it is called?

    I have a critical application in real time, in which I use a piece of DLL function developed in C++.  It is ok?  Make sure any senior developer?

    Thank you in advance.

    The user interface thread is the thread that is used to update the user interface. It's slow. And it's supposed to be that way because humans are slow.

    The call library function node can be configured as this thread to use in the configuration for it dialog box. Please visit the LabVIEW documentation on how to do this.

  • How can I use the BCGTransform function to treat the 16-bit Image?

    Hi ~

    I use LabWindowsCVI8.5 and NI Vision to make the treatment of the Image. When I read the "IMAQ Vision for LabWindowsCVI Reference Manual", I found that the imaqBCGTransform function only supports 8-bit Image, while I do the BCG to turn on 16-bit image. Are there solutions to use the BCGTransform function to deal with the 16-bit Image? Or any other feature that could make the correction Gamma, contrast and brightness on the 16-bit Image?

    Thank you very much!

    because imaqBCGTransform is implemented as a lookup table, we can understand why it is limited to 8-bit images.

    Now let's take a look at the definition of each of this mandate (from the NI Vision Concepts documentation):

    -brightness: a constant added to the components red, green, and blue pixel of color over color, decoding of the process;

    -contrast: a constant multiplication factor applied to the components of the luma and chroma of a pixel of color in color to decoding process.

    -gamma correction: expand high gray-level information in an image while removing information of low level of gray.  (the chapter on lookup tables gives some examples of corrections gamma)

    now that you understand that this transformation is a simple mathematical function, simply calculate the correction for each pixel on your 16-bit images.

    I know not the exact formula used by the imaqBCGTransform function, but you should be able to approach by performing some tests on images 8 bits with the original function... or you can make your own formula... or find one on the net... or you can ask someone at home OR you give the formula...

  • Does anyone have an example VI for using the SendInput function in User32.dll?

    Hi all

    I am creating a VI that creates a click of the mouse.  I looked at the MSDN Web site and found that I need to use the SendInput function in User32.dll.  The problem is that some of the parameters for this function are nested structures.  How to use this function in a call library function node?  Is there already a LabVIEW wrapper for this function?

    Thank you

    MechEman

    I would use rather MouseEvent.  I looked at my VI and it can be cleaned up a bit, but it works for what you want to do.

  • Using the comparison function where 2 data tables various types

    Is it possible to use the comparison function in Labview you to compare 2 arrays of types of different data (e.g. Boolean and double-precision)?

    Would this work?  Nested for loops of index on the TRUE values of the Boolean table.

  • How to copy an image that is in format .pdf using the paint function paste in Word?

    I would like to copy a table that is in a non-protected PDF document using the paint function in accessories to paste it in a Word document that I'm working on. Please help as soon as POSSIBLE.

    Hello, Edward Namalima,.

    1. first open the pdf page you want to copy.

    2. when the page is displayed on your screen, press prtscrn on your keyboard.

    3. a copy of the screen has now sent in the windows clipboard.

    4. now open Paint.

    5. on the Paint toolbar, click on edit and then click on paste. The image will now be pasted in a Paint window. You may need to accept a dialog resize if the image is larger than the current document.

    6. now, from the toolbar to the left of your screen, click on the Selection (the oblong dotted box) tool. With the selection tool, select the entire surface of the table you want to copy. Once selected, click on modifier change again, then select Copy.

    7. now, open Microsoft Word.

    8. then place the cursor where you want the table to set, and then press the CTRL and V together on your keyboard.

    9. the image of the table should now be pasted into your Word document.

    Alternatively, you can use the cutting tool (click on the Start button and type snipping tool in the search field). Select the table you want in the pdf page using the cutting tool and then open word and paste the table in word.

    This forum post is my own opinion and does not necessarily reflect the opinion or the opinion of Microsoft, its employees or other MVPS.

    John Barnett MVP: Windows XP Expert associated with: Windows Expert - consumer: www.winuser.co.uk |  vistasupport.mvps.org | xphelpandsupport.mvps.org | www.silversurfer-Guide.com

  • Why can I not use the scanner function if my ink cartridges are not installed properly?

    The scanner allows just as one scanner I have another product of HP that I use for my printing needs? My all in one (C4580) there is an error that indicates that the ink cartridges have not been installed correctly. I have not used this printer as printer in a long time, but use it as my primary scanner. Is there anyway I can overide the "Cartridghe Print badly installed" so I can use the scanner function? Thank you for your help

    You can find information on how solve the error associated with cartridge you have about your Photosmart C4580 paper here.

    With most of the printers HP if there is a visible error on the printer screen it only lets not to copy, scan or fax.

    I hope this helps.

Maybe you are looking for