Simple Max date pull from several rows with the same employee numbers.

Ok so I'm hoping this is flying over my head because it's almost 3am, but I haven't been able to figure this query out for the last 2hrs, but I like to figure stuff out on my own. I'm wondering why the following statement works fine:
select emp_num, to_char(max(end_date)) as newestdate
from bank_history
where emp_num in ('22964', '21667', '20758', '12739', '12731', '20929', '22795', '20594', '23077', '12588', '21294', '20618', '21204', '22952', '19990', '20632', '03093', '19991', '22951', '07779', '20014', '11981', '06149', '20364', '21103')
and bank_type = 'P' group by emp_num
BUT! When I start to add more columns that I need to see it starts adding the multiple employee numbers again.
select emp_num, bank_type, earn_hrs, used_paid_hrs, used_paid_hrs, to_char(max(end_date)) as newestdate
from bank_history
where emp_num in ('22964', '21667', '20758', '12739', '12731', '20929', '22795', '20594', '23077', '12588', '21294', '20618', '21204', '22952', '19990', '20632', '03093', '19991', '22951', '07779', '20014', '11981', '06149', '20364', '21103')
and bank_type = 'P' group by emp_num, bank_type, earn_hrs, used_paid_hrs, used_unpaid_hrs
The orginal table looks something like this:
EMP_NUM BANK_TYPE EARN_HRS USED_PAID_HRS END_DATE
60393 P 0.58 0 3-Aug-2004
60394 P 7.48 1 28-Oct-2003
60394 P 40 40 28-Oct-2004
60394 P 40 12.4 28-Oct-2005
60395 P 40 40 21-Oct-2004
60395 P 0 0 21-Oct-2003
60395 P 40 40 21-Oct-2005
60397 P 40 39.85 21-Oct-2004
60397 P 0.97 0.97 21-Oct-2003
Much thanks for any direction you can give to help guide me on my way to a solution. If you can help it please don't give me the answer, but try to give me the reason it's not working. I'll never learn if you give it to me right up front lol. Thanks again.
Luke
Message was edited by: trying to fix the table formating sorry it's so unreadable
Luke22

I just give you a prompt:
SQL> with t as (select 1 emp_num, 'A' bank, date '2007-08-01' dt from dual union all
  2             select 1 emp_num, 'B' bank, date '2007-08-02' dt from dual union all
  3             select 1 emp_num, 'C' bank, date '2007-08-03' dt from dual union all
  4             select 2 emp_num, 'A' bank, date '2007-08-05' dt from dual union all
  5             select 2 emp_num, 'B' bank, date '2007-08-04' dt from dual union all
  6             select 3 emp_num, 'A' bank, date '2007-08-07' dt from dual union all
  7             select 3 emp_num, 'C' bank, date '2007-08-08' dt from dual)
  8  --
  9             select emp_num, max(dt) from t
10             group by emp_num
11  /
   EMP_NUM MAX(DT)
         1 03.08.2007
         2 05.08.2007
         3 08.08.2007
SQL>
SQL> with t as (select 1 emp_num, 'A' bank, date '2007-08-01' dt from dual union all
  2             select 1 emp_num, 'B' bank, date '2007-08-02' dt from dual union all
  3             select 1 emp_num, 'C' bank, date '2007-08-03' dt from dual union all
  4             select 2 emp_num, 'A' bank, date '2007-08-05' dt from dual union all
  5             select 2 emp_num, 'B' bank, date '2007-08-04' dt from dual union all
  6             select 3 emp_num, 'A' bank, date '2007-08-07' dt from dual union all
  7             select 3 emp_num, 'C' bank, date '2007-08-08' dt from dual)
  8  --
  9             select emp_num, bank, max(dt) from t
10             group by emp_num, bank
11  /
   EMP_NUM BANK MAX(DT)
         1 A    01.08.2007
         1 B    02.08.2007
         1 C    03.08.2007
         3 A    07.08.2007
         2 A    05.08.2007
         2 B    04.08.2007
         3 C    08.08.2007
7 rows selected
SQL>
SQL> with t as (select 1 emp_num, 'A' bank, date '2007-08-01' dt from dual union all
  2             select 1 emp_num, 'B' bank, date '2007-08-02' dt from dual union all
  3             select 1 emp_num, 'C' bank, date '2007-08-03' dt from dual union all
  4             select 2 emp_num, 'A' bank, date '2007-08-05' dt from dual union all
  5             select 2 emp_num, 'B' bank, date '2007-08-04' dt from dual union all
  6             select 3 emp_num, 'A' bank, date '2007-08-07' dt from dual union all
  7             select 3 emp_num, 'C' bank, date '2007-08-08' dt from dual)
  8  --
  9             select emp_num, max(bank) keep (dense_rank last order by dt) bank, max(dt) from t
10             group by emp_num
11  /
   EMP_NUM BANK MAX(DT)
         1 C    03.08.2007
         2 A    05.08.2007
         3 C    08.08.2007

Similar Messages

  • Every time I create an account with iCloud then try to open it I get wrong ID or password. Even when I enter my birth date I am told it is incorrect. I have done this several times with the same results.

    Every time I create an account with iCloud then try to open it I get an error message: wrong ID or password. Also when I enter my birth date I am told it is incorrect. I have done this several times with the same results.

    Oldcameraman
    Please do not duplicate a thread. The threads are answered as soon as possible. We are not Adobe. Just user to user.
    I have answered your most recent of the duplicates
    Premier Elements 13 Organizer Works. Editor doesn't. Log in doesn't work
    It is uncertain just how far we can go to help you since you do not appear to have Premiere Elements any
    longer.Seems you demanded a refund from Adobe Chat, got it, and now are left with a non purchased program which I
    am not sure can be used.
    Duplicates tend to confuse the person asking the question as well as those attempting to reply. As I suggested in the
    above mentioned thread, try to sort out your situation with Adobe via its Adobe Chat.
    ATR

  • How can i select some row from multiple row in the same group of data

    I want to select some row from multiple row in the same group of data.
    ColumnA        
    Column B
    1                  OK
    1                   NG
    2                   NG
    2                          NG
    3                          OK
    3                          OK
    I want the row of group of
    ColumnA if  ColumnB contain even 'NG'
    row , select only one row which  Column B = 'NG'
    the result i want = 
    ColumnA         Column B
    1                         NG
    2                   NG
    3                          OK
    Thank you

    That's some awful explanation, but I think this is what you were driving at:
    DECLARE @forumTable TABLE (a INT, b CHAR(2))
    INSERT INTO @forumTable (a, b)
    VALUES
    (1, 'OK'),(1, 'NG'),
    (2, 'NG'),(2, 'NG'),
    (3, 'OK'),(3, 'OK')
    SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
    FROM @forumTable f
    LEFT OUTER JOIN @forumTable f2
    ON f.a = f2.a
    AND f.b <> f2.b
    GROUP BY f.a

  • There is a little camera icon on a movie clip when I try to import it to iMovie from my iPad. I have reimported several times with the same result. When I disconnect the iPad I can no longer view the clip. Help!

    There is a little camera icon on a movie clip when I try to import it to iMovie from my iPad. I have reimported several times with the same result. When I disconnect the iPad I can no longer view the clip. Help!

    Hi eawaters,
    If you are having issues importing video from your iPad to your Mac for use in iMovie, you may find the following article helpful:
    iOS: Import personal photos and videos from iOS devices to your computer
    http://support.apple.com/kb/ht4083
    Regards,
    - Brenden

  • Record about my phone (bought in Verizon store and connected to Verizon for 4 years) has been corrupted and now I can not make any changes to my data plan. Several sessions with the technical support and management have not resolved this issue. Each time

    Record about my phone (bought in Verizon store and connected to Verizon for 4 years) has been corrupted and now I can not make any changes to my data plan. Several sessions with the technical support and management have not resolved this issue. Each time technical people and top managers promised that this issue will be resolve tomorrow and they will cal me. Nothing happend!! I can not even cancel my service not just to upgrade it. Completely locked. 
    Any advice?
    Thanks.
    Alex.

    Cannot figure out what your talking about since it makes no sense.
    If you are the account owner you can go to the My Verizon web portal http://www.verizonwireless.com
    You must log in with your cell number and your my Verizon portal password. Not the account pin.
    Once there you can change your plan and services. However repeated incorrect login attempts will lock you out of the site. It a fraud prevention measure.
    1-800-922-0204 call support with your cell number and or account number and account pin and they can assist you.
    If you don't have the information then there is nothing they can do.
    If you can verify who you are they may be able to reset your account access. But only if you are the account owner.
    Good Luck

  • I have photos from several cameras of the same event, how do I combine them?

    I have photos from several cameras of the same events.  How can I sort them together, three pics of the same horse from three cameras side by side; I can't move pics from one camera source to another in a folder.

    Languare is critical since it is all we have to communicate with
    Folders in iPhoto do not hold photos - folders hold only other folders or albums
    If you are speaking of events then you simply merge the events (drag one onto another or select two or more and use the merge events command - for the photos to be "side by side" the three camera's time/date setting will have to be identical as photos will be sorted by time/date - if they are not you can correct by selecting the photos in an event (before merging) and using the adjust time and date command or you can make a smart album for the camera and select the photos and use the adjust time and date command
    LN

  • I would like to use Formcentral form data to populate a pdf with the same fields.  Is that possible?

    I would like to use Formcentral form data to populate a pdf with the same fields.  Is that possible?

    Randy,
    We have an application that I would like to have in Formscentral.  That application is also in a larger PDF file that once filled in populates all the other forms below it (lease, credit check form, ect).  If the Application on Formscentral keep the same field names as the pdf can I pull the data from formscentral and sill populate the old application pdf so that all the forms below it will be also populated. 
    Greg

  • SMQ2 Error :Several modes with the same number  at activity 2N

    Hi,
    We have some Ques stuck in APO inbound "Several modes with the same number  at activity 2N". Can anybody help me to fix this.?
    Sameer.

    Hi Sameer, indeed your issue seems to be linked to PDS creation. Your PDS CIF jobs must be failing if I am not wrong.
    You would need to identify which PDS in APO (or which version in R/3) has issues.
    Go to CQ transaction mentioned earlier, select teh row containing the issue, and then click on the display icon on the right side top. This will show you the entries in the internal tables taht were being passed on in the CIF.
    From here, you need to identify the production version from R/3 that is having issue. I don't have a stuck queue at hand, so can't tell you which table would contain information. Somewhere you would find out the name of the product/location that is having issue, and then you need to check what is the issue with the version. Seems the same mode is being used multiple times in some activity, or in R/3 side, the same resource is being used multiple times in a single activity.
    Thansk - Pawan

  • Firefox will not open after installation. i have tried to install several times with the same results. installation sends a list to firefox each time. need help. willard lee

    will not open after installation. i have tried to install several times with the same results. installation sends a list to firefox each time. need help. willard lee

    Can you attach a screenshot or link to the instructions you are following?
    You are on the 3.6 release and Firefox 7.0.1 is out. You can download and install the latest release from http://www.mozilla.org/en-US/firefox/new/ if you would like to update now. The 3.6 version will be maintained for a while longer, but you should update when you can.

  • Run the data copy and comments copy with the same key

    I want to Run the data copy and comments copy with the same key.
    I tried to challenge in the following way, but it is an error.
    1. Add the process in the process chain [/ CPMB / COPY] process in the process chain that could be new to copy the chain [/ CPMB / COPY_COMMENTS] (see capture)
    2. Select the newly can process chain to add a package, make a change to the script as follows:
    PROMPT(RADIOBUTTON,%TARGETMODE%,"Handling of records",0,{"Copy records with match key","Copy by replacing data in same data region of Entity, Category, Time and Audit ID"},{"0","2"})
    PROMPT(RADIOBUTTON,%RUNLOGIC%,"Select whether to run default logic for stored values after copying",0,{"Yes","No"},{"1","0"})
    PROMPT(RADIOBUTTON,%CHECKLCK%,"Select whether to check work status settings when importing data.",1,{"Yes, check for work status settings before importing","No, do not check work status settings"},{"1","0"})
    PROMPT(COPYMOVEINPUT,%SELECTION%,%TOSELECTION%,"Select the members to COPY and where to",%DIMS%,0)
    INFO(%TEMPNO1%,%INCREASENO%)
    INFO(%ACTNO%,%INCREASENO%)
    INFO(%SELECTION_KEYDATE%,)
    TASK(/CPMB/COPY_COMMENTS,SELECTION,%SELECTION%)
    TASK(/CPMB/COPY_COMMENTS,TOSELECTION,%TOSELECTION%)
    TASK(/CPMB/COPY_COMMENTS,CHECKLCK,%CHECKLCK%)
    TASK(/CPMB/CM_CONVERT,OUTPUTNO,%TEMPNO1%)
    TASK(/CPMB/CM_CONVERT,ACT_FILE_NO,%ACTNO%)
    TASK(/CPMB/CM_CONVERT,SAPPSET,%APPSET%)
    TASK(/CPMB/CM_CONVERT,SAPP,%APP%)
    TASK(/CPMB/CM_CONVERT,SELECTION,%SELECTION%)
    TASK(/CPMB/CM_CONVERT,TOSELECTION,%TOSELECTION%)
    TASK(/CPMB/CM_CONVERT,KEYDATE,%SELECTION_KEYDATE%)
    TASK(/CPMB/CLEAR_SOURCE_CUBE,CHECKLCK,1)
    TASK(/CPMB/CLEAR_SOURCE_CUBE,SELECTION,%TOSELECTION%)
    TASK(/CPMB/CLEAR_SOURCE_CUBE,KEYDATE,%SELECTION_KEYDATE%)
    TASK(/CPMB/CLEAR_SOURCE_CUBE,DUMPLOADMODE,3)
    TASK(/CPMB/APPEND_LOAD,PREPROCESSMODE,0)
    TASK(/CPMB/APPEND_LOAD,TARGETMODE,0)
    TASK(/CPMB/APPEND_LOAD,INPUTNO,%TEMPNO1%)
    TASK(/CPMB/APPEND_LOAD,ACT_FILE_NO,%ACTNO%)
    TASK(/CPMB/APPEND_LOAD,RUNLOGIC,1)
    TASK(/CPMB/APPEND_LOAD,CHECKLCK,1)
    TASK(/CPMB/APPEND_LOAD,KEYDATE,%SELECTION_KEYDATE%)

    We performed similar transfer of data from one planning model to another using DM package linked to BADI. In your scenario there is additional complexity of doing lookup from DSO and should be possible.
    Also check these references for performing lookup in DSO.
    abap code to populate data from DSO
    something about SAP: How to look for DSO&amp;#8217;s tables?

  • Error occurred in deployment step 'Install app for SharePoint': The provided App differs from another App with the same version and product ID.

    I am facing this problem while start debugging the Provider-Hosted app through VS2013. I want to deploy the app with same version. So please let me know any solution
    to remove the app instance from office365 online, so that I can deploy the same app with same version on the specified "Developer Site".
    Note: If I change the version in AppManifesst.xml file then this problem/error gets resolved. But I want to deploy with the same version as
    per my business requirement.
    The actual error renders while I click to "Start" button of the Visual Studio 2013 to deploy the provider-hosted app, for the sake
    to deploying it on say "ABC" site collection (i.e. developer site). I work on office365 online. Therefore, request you to please provide the solution for SharePoint online office 365. The occurrences is:
    "Error occurred in deployment step 'Install app for SharePoint': The provided App differs from another App with the
    same version and product ID."
    Please assist me anyone. It will be so kind of you.....
    Naveen Kumar
    Steria India Ltd.

    Did you updated the  AppManifest.xml file
    and change the version.
    If this helped you resolve your issue, please mark it Answered

  • TS1627 Please Help. I received 4 emails from 1 person with the same message heading. The emails were automatically grouped by Mail. I replied to the latest mail in the conversation. Once sent the other messages in the conversation disappeared. I NEED THEM

    Please Help. I received 4 emails from 1 person with the same message heading. The emails were automatically grouped Apple Mail. I replied to the latest mail in the conversation. Once sent the other messages in the conversation disappeared. I NEED THEM BACK! They all had very important attachments. I have tried looking for them in deleted items, even though I didn't throw any of them away, still cant find them. Never had this problem before. I'm pretty sure its a setting somewhere. Also tried expanding all conversations, no luck. Searching for the mails under the sent email address, no luck.
    I'm sure they are not deleted but have somehow been hidden by Mail. Very frustrating.
    Thanks in advance for any help.
    Kash.

    I have found found out what has happened. I had requested a statement dating back to April 2012 from a supplier. They replied back with the latest statementof 2013 only but used the same subject heading as the previous monthly statements. Apple Mail automatically grouped these and I thought that they were sent altogether. As soon as I replied to the last email all other the previous emails ungrouped from the conversation leaving me lost as to where they had gone. They were all still sitting in my inbox but no longer part of the trcked conversation. I searched under the subject heading and all individual mails were all still there. (feeling stupid - )

  • Firefox keeps saving my tabs from several months ago - the same tabs! Even though I close them, the next time I restart, there they are. I was using a previous version of FF, now upgraded to 6 and same thing is happening.

    Firefox keeps saving my tabs from several months ago - the same tabs! Even though I close them, the next time I restart, there they are. I was using a previous version of FF, now upgraded to 6 and same thing is happening.

    Thanks for the reply. I never get the option to "Restore Previous History" from History. I don't even have the box checked that asks to delete the history when Firefox closes. I don't know what's wrong, no matter what, I always lose everything. I have the box marked "Show my windows and tabs from last time" for when I open Firefox, but it never shows that, just my homepage. Also, when I check my History, it only shows the pages that I opened since I started Firefox, nothing from before. Even if I were to open up 10 pages now, close Firefox, and open it, the history would only show the homepage that opened this time, not any of the 10 pages that I opened 5 minutes ago.

  • 2 SD cards with the same file numbers

    How do I burn 2 SD cards with the same file numbers. Always says do I want to replace photo with the same number.

    Welcome to the Apple Discussions. Rename one set of photos by renaming them in iPhoto with the Photos ➙ Batch Change ➙ Title to Text menu option and then export to the Desktop with the option to use the Title as the new file name.
    Or, put one each set of photos in their own folder and put the two folders on the memory card.
    Happy Holidays

  • Several users with the same login/Customize

    This may seem a stupid question. But
    I have several users login ,by department rather than creating hundreds and grouping them.
    Then on the reports I have created I have put quite a lot of customizable options. I have not given them the save button on the customize page, however as I thought this would effect the defaults for other users logging in with the same login.
    However I am finding that even without this if they customize a report. Then another person logs in they pick up the changes they have made. Is there a way to stop this?
    Thanks,
    Craig

    Craig,
    If I understand it right, you basically are having several users log into one account, this should never be done, especially in OLTP environments or even OLAP where the data is sensitive. You'll have the issue you described (standard features break or don't work as expected), limit your auditing options (the database and the provider can't tell who did what all the time), increase complexity of user management (when user A no longer needs access, how can you deny him/her access without effecting those that still need access), limits development of new features (method is non-standard) and generally causes security head-aches (auditing, user management complexity, etc.). Users are not expensive objects (sessions are but you'll have as many either way).

Maybe you are looking for