Need to separate lines, with the help of the distinct clause

I have according to requirement

Organization of end startdate EmpID
1 O1 from January 1, 2008
2 on January 2, 2008 July 31 08 O1
3 2 January 2008 31 July 08 O1
4 2 January 2008 31 July 08 O2
5 2 January 2008 31 July 08 O2
6 2 January 2008 31 July 08 O2
7 2 January 2008 31 July 08 O3
8 2 January 2008 31 July 08 O3


My requirement is to get a sql query which report me something like that

Organization of end startdate EmpID
1 O1 from January 1, 2008
4 2 January 2008 31 July 08 O2
7 2 January 2008 31 July 08 O3

Any empid, startdate, which is fine for a given organism (IE organization should be separate)

concerning
Vikas

Published by: user634784 on January 19, 2009 04:05

In reality... N °

Sure about that?

SQL>  select organisation,
  2     min(startdate) keep(dense_rank first order by empid asc) startdate,
  3     min(enddate) keep(dense_rank first order by empid asc) enddate,
  4     min(empid) keep(dense_rank first order by empid asc) empid
  5     from t
  6    group by organisation
  7  /

OR STARTDATE ENDDATE        EMPID
-- --------- --------- ----------
O1 01-JAN-08                    1
O2 05-JAN-08 31-JUL-08          4
O3 02-JAN-08 31-JUL-08          7

Tags: Database

Similar Questions

  • How installed / move Creative could again mini. Original mini lost sound. Unable to get through endless lists. Need a direct line with the customer service.

    Down loaded Creative could Macmin in January... Mini lost it is solid, put out.  New mini can not get through all the forms ADOBE, passwords, etc.  Have no serial number of the program, but my purchases are well documented.

    Had to change passwords several times.  I need a quick and direct link by e-mail or by phone at ADOBE.  Displacement of the programs has been easy.

    Gerry

    Hello

    The CC from Adobe, you can download simple on your new machine by following the steps mentioned in the help below document:

    Using creative cloud | Download, install, update or uninstall applications

    In case the problem persists, please contact support:

    Contact the customer service

    Kind regards

    Sheena

  • Update lines with the info from the other rows in the same Table.

    I'm trying to update the lines with the information of the same table. The table is loaded with information from a report that runs and there must be a new entry every month, but I would like to bring some of the info from the last month. This statement below works but updates all rows in the new load table and in my test case, I only did a few game only like 5 files need to get updates. It is an example of what I'm trying to do. If I add this (C2. COL_INVC_ID = C1. COL_INVC_ID) until the last "* where *" statement get an invalid identifier for 'C2 '. COL_INVC_ID ". So what I'm doing wrong here? How can I update only the lines where also in recent months run?

    Thanks in advance for any help!

    ------------
    Update OpenIssues OI1
    Together (OI1. NUM, OI1. Status, OI1. Code, OI1. LastModifiedDate) =
    (Select ios2. NUM, ios2. Status, ios2. Code, ios2. LastModifiedDate
    Of OpenIssues ios2
    Where OI2.num = OI1.num and ios2. TableLoadDate = TO_DATE (January 31, 2012 00:00:00 ',' ' the HH24: MI: SS DD/MM/YYYY)
    )
    Where and OI1. TableLoadDate = TO_DATE (February 29, 2012 00:00:00 ',' ' the HH24: MI: SS DD/MM/YYYY)
    ------------


    SQLMe

    As Frank suggested merger is much effective here, go...

      create table  temp
    as(
    select 1 eno, 1 amt , sysdate load_date from dual union all
    select 1 eno, 2 amt , add_months(sysdate,1) load_date from dual union all
    select 2 eno, 1 amt , sysdate load_date from dual union all
    select 2 eno, 2 amt , add_months(sysdate,1) load_date from dual
    );
    
    merge into temp t
    using (select eno, amt, load_date
             from temp
            where trunc(Load_Date) = TO_DATE('05/30/2012', 'MM/DD/YYYY')) s
    on ((s.eno = t.eno) and trunc(t.Load_Date) = TO_DATE('06/30/2012', 'MM/DD/YYYY'))
    when matched then
      update set t.amt = s.amt;
    commit;
    
    select * from temp;
    
  • Drawing line with the mouse clicks on picture indicator

    Hello

    I need to import a JPG file in an image control, draw a line in 2 clicks, read bothe XY positions and perform some basic trigonometry. Any simple or striaghtforward way to draw the line with the mouse and read thos passay on the bitmap (positions relative pixel)?

    Thanks in advance,


  • My original XP Pro disc is SP2. I've updated to SP3 and now I have corrupted files and need to repair windows with the disc.

    My original XP Pro disc is SP2. I've updated to SP3 and now I have corrupted files and need to repair windows with the disc. When I put disc SP2 in it tells me that it is a work old version and custom. How to make a disc with SP3 top to repair my OS?

    Hi DFPI.

    I suggest you to uninstall Service Pack 3 temporarily on your computer.

    How to remove Windows XP Service Pack 3 from your computer

    Later, try to repair the computer with the Windows XP disc and check if it works.

    Later, reinstall the Service Pack 3 after the computer repair.

    Reference: Description of Windows XP and Windows Server 2003 System File Checker (Sfc.exe)

    Hope the helps of information.

    Please post back and we do know.

  • I use creative cloud of Adobe Premiere Pro and it does not allow me to drag. In the line of time, only the audio files of the video MXF files. Plays in the video source, but does not allow me to change on the time line with the. MXF files.

    I use creative cloud of Adobe Premiere Pro and it does not allow me to drag. In the line of time, only the audio files of the video MXF files. Video plays in the source window, but does not to drag me and thenedit on the time line with the. MXF files. audio will slide to the time line, but not the video. Interestingly, not later than end of December 2015 it allowed me to change with .mxf files, but no, it won't. Any help out there?

    Neil, get it fixed, I do not have the video channels set correctly on the left

    side of the line of the time. Learn the new adobe; Thank you

    Monday, February 15, 2016 13:20, R Neil Haugen [email protected]>

  • Select the line with the smallest Beach

    Hello
    I am trying to build a complex query...
    He must select the line with the inner range...

    I'll explain for example:
    Location of poolsize ID value
    1 32 8
    2 40 6
    3 42 8
    4-36-3

    I want to select the line where the fork between value and value + poolsize is shared also with the other location...
    so:
    1 is 32-40 (in A place)
    2 is 40-46 (in place)
    3 is 42-48 (location B)
    4 is 36-39 (at location B)

    4 is located at 1 (and there are different places...) so sql must return to the fourth line.

    Any help will be appreciated!

    Thank you
    fcbman

    Hello

    fcbman1899 wrote:
    Hello
    I am trying to build a complex query...
    He must select the line with the inner range...

    I'll explain for example:
    Location of poolsize ID value
    1 32 8
    2 40 6
    3 42 8
    4-36-3

    Whenever you have a problem, please post CREATE TABLE and INSERT statements for your sample data, in order to let the people who want to help you re-Ridge the problem and test their ideas.
    See the FAQ forum {message identifier: = 9360002}

    I want to select the line where the fork between value and value + poolsize is shared also with the other location...
    so:
    1 is 32-40 (in A place)
    2 is 40-46 (in place)
    3 is 42-48 (location B)
    4 is 36-39 (at location B)

    4 is located at 1 (and there are different places...) so sql must return to the fourth line.

    To find all the rows that are within the range of at least one other line with another location:

    SELECT     *
    FROM     table_x  m
    WHERE     EXISTS (
                 SELECT  1
                 FROM        table_x
                 WHERE   location          != m.location
                 AND        value          <= m.value
                 AND        value + poolsize     >= m.value + m.poolsize
                )
    ;
    

    When you talk of the "" * most * inner range ", do you mean that you might have another line, such as"

    INSERT INTO table_x (id, vlue, poolsize, location) VALUES (5, 37, 1, 'C');
    

    which is inside the range of id - 4, and that's why you wouldn't have id = 4? If so, include examples in the results and data sample yout. You can do this with a query CONNECT BY, or, depending on your version of Oracle, a WITH recursive clause.

  • Compare lines with the contractor ID and choose the line with Min Date rental

    Hello

    I have a scenario where I need a line with the Minimum of the Pavilion main 'p' Hire Date whenever there are multiple records with the same ID of the contractor. I need a SQL for this

    For example

    Contractor_ID name Hire_Date end_date Primary_Flag

    123 Tom 9/11/2011-9/11/2012

    123 Tom 9/12/2012-5/12/2012


    I need to score the first line of 'P '. It is an example where there are thousands of discs where I have to mark. Some cases it can be 3 or 4 files to contractor_id even where I need a 'P' flag for recording with Min Hire_Date


    Thank you
    RAM

    Hello

    If you want to ensure that only 1 row by entrepreneur is marked "P", if the lines are the same, then I suggest you do something on the ROW_NUMBER analytic function, like this:

    SELECT       contractor_number
    ,       full_name
    ,       job_title
    ,       hire_date
    ,       end_date
    ,       CASE
               WHEN  1 = ROW_NUMBER () OVER ( PARTITION BY  contractor_number
                                                    ORDER BY          hire_date
                                  ,                end_date     DESC
                                )
               THEN  'P'
           END          AS primary_flag
    FROM       contractor
    ORDER BY  contractor_number
    ,            hire_date
    ,       end_date
    ;
    

    Output:

    CONTRACTOR
       _NUMBER FULL_NAME  JOB_TITLE  HIRE_DATE  END_DATE   P
    ---------- ---------- ---------- ---------- ---------- -
       1862180 Tom        Developer  8/01/2011  11/30/2012 P
       1862180 Tom        Developer  12/01/2012 11/30/2013
       1862181 Sam        Developer  9/01/2012  9/30/2012
       1862181 Sam        Developer  9/01/2012  12/30/2012
       1862181 Sam        Developer  9/01/2012  12/30/2012 P
    
  • Need to null values with the values of filling the date before weekend/holidays

    I have a table with a Date column, column Type and rate column.

    The problem is when the weekends and holidays, column Type and rate column are null.

    I need all null values with the values of Type and fill rate before that date is the weekend and public holidays.

    Example:

    I have:

    RATE OF TYPE DATE
    07/01/2010 4510 PM 3.71
    07/01/2010 CETE28 4.59
    07/01/2010 TIIE28 4.95
    07/02/2010 4510 PM 3.82
    07/02/2010 CETE28 4.63
    07/02/2010 TIIE28 5.11
    * NULL NULL 07/03/2010 *.
    * NULL NULL 07/04/2010 *.
    07/05/2010 4510 PM 3.91
    07/05/2010 CETE28 4.74
    07/05/2010 TIIE28 5.25

    Will be:

    RATE OF TYPE DATE
    07/01/2010 4510 PM 3.71
    07/01/2010 CETE28 4.59
    07/01/2010 TIIE28 4.95
    07/02/2010 4510 PM 3.82
    07/02/2010 CETE28 4.63
    07/02/2010 TIIE28 5.11
    * 07/03/2010 4510 PM 3.82*
    * 07/03/2010 CETE28 4.63*
    * 07/03/2010 TIIE28 5.11*
    * 07/04/2010 4510 PM 3.82*
    * 07/04/2010 CETE28 4.63*
    * 07/04/2010 TIIE28 5.11*
    07/05/2010 4510 PM 3.91
    07/05/2010 CETE28 4.74
    07/05/2010 TIIE28 5.25

    What could I do?

    Hello

    You can use the analytic LAST_VALUE function to get the last day of work before each date into your table. It will be the same as the current day for every day of work.
    Do it a self-join to combine each current line (c) with the last day of work (l):

    WITH     got_last_work_day     AS
    (
         SELECT     dt, type, rate
         ,     LAST_VALUE ( CASE
                        WHEN  type  IS NOT NULL
                        THEN  dt
                       END
                       IGNORE NULLS
                      ) OVER (ORDER BY dt)     AS last_work_day
         FROM     table_x
    )
    SELECT       c.dt, l.type, l.rate
    FROM       got_last_work_day     c
    JOIN       got_last_work_day     l  ON       (    c.dt          = l.dt
                             AND  c.type          = l.type
                             )
                           OR     (    c.last_work_day     = l.dt
                             AND  c.type          IS NULL
                             )
    ORDER BY  c.dt
    ,       l.type
    ;
    

    Among other things, I guess that the type is NULL if (and only if) the line represents a holiday or weekend, and that the combination (dt, type) is uniuqe.

  • What am I I did wrong, imported the video is not in line with the audio.

    Hi I have imported video on a digital camera Fujifilm, A850 and that you want to change in the first Elements 7, but the sound is not in line with the Visual.

    I tried reading upwards and by changing the control, but so far without success.

    What should I do?

    Help, please.

    Your camera produces AVI with MJPEG codec. And your problem is quite common that Premiere Elements may have problems with MJPEG files. Generally re - install a MJPEG codec will solve the problem. You can try it free:
    http://www.free-codecs.com/Motion_JPEG_Codec_download.htm

    Otherwise, you can open the file in Windows Movie Maker and export it as a DV - AVI wil be compatible with PE7.
    http://www.adobeforums.com/webx/.3bc247e2

  • Need Windows XP Prof. with the German language

    Dear friends,.
    I have my laptop in Holland bought.
    My Labtop Windows language is English, but I need Windows XP Prof. with the German language.
    How can I install the new Version of Windows in my Labtop?
    Do I have to buy a German version of Win XP Prof?

    Hello

    I suppose that you bought your laptop in the Netherlands.
    Unfortunately, you need a German original version of Win XP.
    After new Win XP installation, you can download ad install all necessary Toshiba drivers from the Toshiba download or the tools & utility cd page.

    Good bye

  • How to draw a line (with the line segment tool) then draw another line, from those previous anchor point. When I try immediately draw another line on the other anchor lines it try to turn instead.

    I'm following a course of basic fundamental illustrator on Lynda. The video of "draw straight lines" is troubling me. They draw a line with the line segment and then draw another line coming out the anchor point at an angle.

    Here's where it is troubling me - when I try to drag a line to the anchor point trying to transform the first line, I drew. (the line cursor turns into a selection tool) I can't draw another line connecting the first.

    Advice would be great because it's driving crazy me.

    See you soon,.
    Kyle

    Yes, it is irritating. You must clear the previous line first. If you want to make sure that both ends are perfectly aligned, start by turning on the guides. If you want two lines to be part of the same way, you should use the tool pen instead.

  • How to animate a line with the pen tool to give the impression that it is plotted?

    How to animate a line with the pen tool to give the impression that it is plotted?

    Or you can choose the pen tool (g), set the padding to zero and the race to what you want, then draw a path, then press U twice to reveal all of the properties that have been changed for the layer, and then click Add (top-right) and select Connect the tracks.

    To make the race work just animate the start or end point and sent to paint on original or reveal original or normal.

  • I'm drawing a curved line with the pen tool, but he fills in a solid form.  I want only the line - what I have to change?

    I'm drawing a curved line with the pen tool, but he fills in a solid form.  I want only the line - what I have to change?

    pmreagans,

    Set the fill to zero at the bottom of the Toolbox.

  • Line with the polygon intersection points

    I have a (multi point) line that crosses a polygon and I can find the points of intersection

    See this site for example: find the Points of Intersection between the line and & amp; #160; Polygon

    However, I would get the multi point original line WITH the points of intersection...

    How could do?

    Essentially for a line that crosses a polygon, I have returned...

    a new line which consists of points of origin AND the intersection of points

    Thanks in advance

    Where did you get the geometry intersecting from?

    Table of Ansdo_elem_info does not match your definition of 2005 multipoint, I think.

    This should be SDO_ELEM_INFO_ARRAY (3,1,1, 1,1,1, 7,1,1, 5,1,1) instead of (1,2,1).

    Then the union result geom is a line of 2002 has opposed to your example that returns a collection of 2006.

    And you will see that these points are where you expect them to be. (11R2 test)

    Luke

Maybe you are looking for