Help to solve query

Dear all
could anyone help to solve and explain this query?
Write a query to display the last names of employees who have one or more coworkers in
their departments with later hire dates but higher salaries.
The tables (employees and departments) exist in HR schema
Thanks.

select employees.last_name last_name --display the last names
from hr.employees employees
where exists ( --who have one or more
select 1
from hr.employees coworkers
where coworkers.department_id = employees.department_id --coworkers in their departments
and coworkers.employee_id <> employees.employee_id --except himself
and coworkers.hire_date > employees.hire_date --later hire dates
and coworkers.salary > employees.salary --higher salaries
Edited by: satoru4fun on 14/06/2012 11:01
Sorry, mistake the date comparison.
Replace it as follow:
and coworkers.hire_date < employees.hire_date --later hire dates                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Help in Matching Query

    How I can get the expected output. Query should get result which exactly match the 'SAP'. If anything is extra or doesn't match then should ignore.
    create table #main (Code char(10), SAP char(6))
    insert into #main values ('AS012','GGG')
    insert into #main values ('AS012','HHH')
    insert into #main values ('AS012','JJJ')
    insert into #main values ('AS012','KKK')
    insert into #main values ('AS013','GGG')
    insert into #main values ('AS013','HHH')
    insert into #main values ('AS013','JJJ')
    insert into #main values ('AS013','KKL')
    insert into #main values ('AS014','GGG')
    insert into #main values ('AS014','HHH')
    insert into #main values ('AS014','JJJ')
    insert into #main values ('AS014','KKK')
    insert into #main values ('AS014','MMM')
    Select distinct CODE from #main where SAP in ('GGG','HHH','JJJ','KKK')
    Result should be:
    CODE
    AS012                   -- (This code-AS012 exactly match the SAP- ('GGG','HHH','JJJ','KKK') which is in SELECT query)

    this?
    DECLARE @FilterList varchar(1000)='GGG,HHH,JJJ,KKK'
    SELECT m.Code
    FROM (SELECT DISTINCT Code FROM #main)m
    CROSS JOIN dbo.ParseValues(@FilterList,',')f
    LEFT JOIN #main t
    ON t.Code = m.Code
    AND t.SAP = m.Val
    GROUP BY m.Code
    HAVING SUM(CASE WHEN t.Code IS NULL THEN 1 ELSE 0 END) = 0
    ParseValues UDF is here
    http://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Need help in solving error

    i am getting error as Redo sequence 9165 no longer available in online logs for thread 1 without ... without archiving enabled, SQL <SELECT MAX(sequence#) FROM v$log WHERE thread# = :ora_thread AND status ... 'CURRENT', 'ACTIVE')>, error retrieving redo file name for sequence 16, archived = 1, use_alternate = 0Not
    actually it was capturing till a date, but after that extraction has stopped and i see this error,
    please can anyone help in solving this issue

    will you please elaborate your query? not able to understand.

  • Need helping in writing query for finding percentage of duration

    Can any one please help in writing query for this.
    The table is like this :-
    ID     Region     Month     Duration
    I1 R1     Jan     80
    I2     R2     Jan     70
    I3     R1     Jan     70
    I4     R3     Jan     40
    I5     R1     Feb     80
    I6     R2     Feb     30
    I7     R3     Mar     100
    I want to write a query to find
    % of duration for each and every region against each and every month.
    Please help in solving this query. I am in urgent need of this.
    Thanks in advance.

    I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
    Nicolas.

  • Need help to solve update querry for multiple records.

    Could any of you please provide update querry for the following scenario.
    Requiremnt:
    1. Update the UNIQUE_ID of record ( same Identifier and Identifier_code
    where END_Date is not null) with the UNIQUE_ID of the record (( same  Identifier and Identifier_code
    where END_Date  is null).
    2. If More than one NULL in END_date then update UNIQUE_ID with max(EFFective_Date) of UNIQUE_ID
    Source  data
    UNIQUE_ID
    Identifier
    Identifier_code
    EFFective_Date
    END_Date
    1
    777
    abc
    2/14/2014 11:15
    2/28/2014 9:00
    1
    777
    abc
    2/21/2014 9:00
    3/7/2014 9:02
    2
    777
    abc
    2/28/2014 9:00
    3/14/2014 9:02
    2
    777
    abc
    3/7/2014 9:02
    3/14/2014 9:02
    2
    777
    abc
    3/14/2014 9:02
    NULL
    5
    888
    xyz
    2/14/2014 11:15
    2/28/2014 9:00
    5
    888
    xyz
    2/21/2014 9:00
    3/7/2014 9:02
    5
    888
    xyz
    2/28/2014 9:00
    3/14/2014 9:02
    6
    888
    xyz
    3/7/2014 9:02
    NULL
    7
    888
    xyz
    3/14/2014 9:02
    NULL
    OutPUT .
    UNIQUE_ID
    Identifier
    Identifier_code
    EFFective_Date
    END_Date
    2
    777
    abc
    2/14/2014 11:15
    2/28/2014 9:00
    2
    777
    abc
    2/21/2014 9:00
    3/7/2014 9:02
    2
    777
    abc
    2/28/2014 9:00
    3/14/2014 9:02
    2
    777
    abc
    3/7/2014 9:02
    3/14/2014 9:02
    2
    777
    abc
    3/14/2014 9:02
    NULL
    7
    888
    xyz
    2/14/2014 11:15
    2/28/2014 9:00
    7
    888
    xyz
    2/21/2014 9:00
    3/7/2014 9:02
    7
    888
    xyz
    2/28/2014 9:00
    3/14/2014 9:02
    7
    888
    xyz
    3/7/2014 9:02
    NULL
    7
    888
    xyz
    3/14/2014 9:02
    NULL
    Thanks in advance.

    Hi Vikash,
    This query will not produce results as per requirement:
    Try it with following data
    Insert into @TempTABLE values (1,777,'abc','2/14/2014 11:15','3/14/2014 9:02')
    Insert into @TempTABLE values (1,777,'abc','2/21/2014 9:00','3/14/2014 9:02')
    Insert into @TempTABLE values (2,777,'abc','2/28/2014 9:00','3/14/2014 9:02')
    Insert into @TempTABLE values (2,777,'abc','3/7/2014 9:02','3/14/2014 9:02')
    Insert into @TempTABLE values (2,777,'abc','3/14/2014 9:02',NULL)
    Insert into @TempTABLE values (5,888,'xyz','2/14/2014 11:15','3/14/2014 9:02')
    Insert into @TempTABLE values (5,888,'xyz','2/21/2014 9:00','3/14/2014 9:02')
    Insert into @TempTABLE values (5,888,'xyz','2/28/2014 9:00','3/14/2014 9:02')
    Insert into @TempTABLE values (7,888,'xyz','3/7/2014 9:02',NULL)
    Insert into @TempTABLE values (6,888,'xyz','3/14/2014 9:02',NULL)
    as per the problem statement, all records having 888,'xyz' should be updated with 6 not 7 as max effective date is associated with 6 not 7.
    Ashutosh
    Nope.
    can you check the original post first. It clearly states output as having 7 as id for all the records with 888,xyz
    also your above posted sample data is different from original sample data as you've dates jumpled up for the records with ids 6 and 7
    Please see the illustration for original sample data
    --sample table for illustration
    declare @t table
    (UNIQUE_ID int,Identifier int,Identifier_code varchar(100),EFFective_Date datetime ,END_Date datetime)
    --populate original sample data
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (1, 777, N'abc', CAST(0x0000A2D200B964F0 AS DateTime), CAST(0x0000A2E0009450C0 AS DateTime))
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (1, 777, N'abc', CAST(0x0000A2D9009450C0 AS DateTime), CAST(0x0000A2E70094DD60 AS DateTime))
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (2, 777, N'abc', CAST(0x0000A2E0009450C0 AS DateTime), CAST(0x0000A2EE0094DD60 AS DateTime))
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (2, 777, N'abc', CAST(0x0000A2E70094DD60 AS DateTime), CAST(0x0000A2EE0094DD60 AS DateTime))
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (2, 777, N'abc', CAST(0x0000A2EE0094DD60 AS DateTime), NULL)
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (5, 888, N'xyz', CAST(0x0000A2D200B964F0 AS DateTime), CAST(0x0000A2E0009450C0 AS DateTime))
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (5, 888, N'xyz', CAST(0x0000A2D9009450C0 AS DateTime), CAST(0x0000A2E70094DD60 AS DateTime))
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (5, 888, N'xyz', CAST(0x0000A2E0009450C0 AS DateTime), CAST(0x0000A2EE0094DD60 AS DateTime))
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (6, 888, N'xyz', CAST(0x0000A2E70094DD60 AS DateTime), NULL)
    INSERT @t ([UNIQUE_ID], [Identifier], [Identifier_code], [EFFective_Date], [END_Date]) VALUES (7, 888, N'xyz', CAST(0x0000A2EE0094DD60 AS DateTime), NULL)
    --do the update
    UPDATE t
    SET UNIQUE_ID = MaxID
    FROM
    SELECT MAX(CASE WHEN END_DATE IS NULL THEN UNIQUE_ID END) OVER (PARTITION BY Identifier,Identifier_code) AS MaxID,UNIQUE_ID
    FROM @t
    )t
    WHERE UNIQUE_ID <> MaxID
    AND MaxID IS NOT NULL
    --now check the output
    SELECT * FROM @t
    The output is as below
    UNIQUE_ID Identifier Identifier_code EFFective_Date END_Date
    2 777 abc 2014-02-14 11:15:00.000 2014-02-28 09:00:00.000
    2 777 abc 2014-02-21 09:00:00.000 2014-03-07 09:02:00.000
    2 777 abc 2014-02-28 09:00:00.000 2014-03-14 09:02:00.000
    2 777 abc 2014-03-07 09:02:00.000 2014-03-14 09:02:00.000
    2 777 abc 2014-03-14 09:02:00.000 NULL
    7 888 xyz 2014-02-14 11:15:00.000 2014-02-28 09:00:00.000
    7 888 xyz 2014-02-21 09:00:00.000 2014-03-07 09:02:00.000
    7 888 xyz 2014-02-28 09:00:00.000 2014-03-14 09:02:00.000
    7 888 xyz 2014-03-07 09:02:00.000 NULL
    7 888 xyz 2014-03-14 09:02:00.000 NULL
    Now compare it with original output and you'll find they're the same
    UNIQUE_ID Identifier Identifier_code EFFective_Date END_Date
    2 777 abc 2/14/2014 11:15 2/28/2014 9:00
    2 777 abc 2/21/2014 9:00 3/7/2014 9:02
    2 777 abc 2/28/2014 9:00 3/14/2014 9:02
    2 777 abc 3/7/2014 9:02 3/14/2014 9:02
    2 777 abc 3/14/2014 9:02 NULL
    7 888 xyz 2/14/2014 11:15 2/28/2014 9:00
    7 888 xyz 2/21/2014 9:00 3/7/2014 9:02
    7 888 xyz 2/28/2014 9:00 3/14/2014 9:02
    7 888 xyz 3/7/2014 9:02 NULL
    7 888 xyz 3/14/2014 9:02 NULL
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Please help me this query

    Plz help me this query:
    Create a query that displays the employees last name and indicates the amounts of their annual salaries with *. Each * signifies a thousand $'s.
    EG. If the salary of an employee with last name king is 2000 then it should appear as follows:
    King **
    2 (*) for 2 thousand.
    Thanks in advance

    Hi,
    I was able to solve this query on my own. For those who might face a problem in future the solutionto it is:
    SELECT rpad(last_name, length(last_name) + (salary/1000), '*') AS employee_and_their_salaries
    FROM employees;
    Thanks

  • I am not able to launch FF everytime i tr to open it, it says FF has to submit a crash report, i even tried doing that and the report was submitted too, but stiil FF did not start, and the problem still persists, please help me solve this issue in English

    Question
    I am not able to launch FF everytime i try to open it, it says FF has to submit a crash report,and restore yr tabs. I even tried doing that and the report was submitted too, but still FF did not start, and the problem still persists, please help me solve this issue
    '''(in English)'''

    Hi Danny,
    Per my understanding that you can't get the expect result by using the expression "=Count(Fields!TICKET_STATUS.Value=4) " to count the the TICKET_STATUS which value is 4, the result will returns the count of all the TICKET_STATUS values(206)
    but not 180, right?
    I have tested on my local environment and can reproduce the issue, the issue caused by you are using the count() function in the incorrect way, please modify the expression as below and have a test:
    =COUNT(IIF(Fields!TICKET_STATUS.Value=4 ,1,Nothing))
    or
    =SUM(IIF(Fields!TICKET_STATUS=4,1,0))
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Can you help me solve my aspect ratio issue?

    Hey guys,
    I'm posting this in hopes that someone can help me solve an aspect ratio issue with a project that I have to finish by tomorrow.
    I'm trying to avoid having to re-edit the entire thing.
    I shot the project with my Nikon D7000 DSLR. in 720p 30p (29.97)
    I am running Adobe Premiere Pro CS5 (the trial version).  I have the full version of Adobe Premiere Pro CS3.
    The reason I was working with the trial is that CS3 can't handle the H.264 MOVs that the D7000 records.
    You can work with a timeline, but if you try to export anything, it never works.  I always have to convert my footage to ProRes MOVs with MPEG Streamclip before I can work with them is CS3.  That takes a lot of time and a lot of hard drive space.  After much research, I found out that CS5 is the way to go for DSLR footage.  I just need to save up my pennies for the upgrade.
    So I thought I'd edit this short (1 minute) project with the trial to see how CS5 works with the D7000 footage.
    Upon installing the trial program, I found that the project presets were limited.  I knew this ahead of time because it's clearly stated on the Adobe's website.
    But I wasn't aware how limited they are.
    Since "DSLR 1280x720p 30p" is not an option with the trial, I was going to use HDV 720p 30p.  But that was not an option either!
    So basically, my only option for 16x9 30p was "DV NTSC Widescreen".  It's my understanding that this is 864x480 (in square pixel aspect ratio) or 720x480  (in widescreen pixel aspect ratio)   I needed the output file to be 864x486.  I downsized the footage to 69% in the "Video Effects: Motion" setting so it looked correct in the project.  I didn't think about those extra 6 pixels until I outputed the file and saw thin black lines on the top and bottom.  My guess is that Premiere is adding black pixels because my project is technically 720x480 (1.2121)
    Any thoughts on how I can get a clean 864x486 export?  I'd rather not re-edit the whole thing...which I would have to do in CS3 after I spent a few hours converting the original files in MPEG Streamclip.  I don't know if there is a way to export something out of CS5 and then open a new project in CS3 to make this work.
    Thanks in adavance!
    - Jordan

    On export, just crop a few pixels off of each side; that'll let the image scale correctly to the output frame size without black bars.
    I'm not running the trial, but you should still be able to create a custom sequence preset using the Desktop editing mode. Just switch over to the General tab when you create a new sequence, and choose "Desktop" from the editing modes. Set the rest of the parameters as you need them.
    Even easier: once you've imported your footage, just drag a clip to the New Item icon at the bottom of the project panel; a sequence will be created matching your footage parameters. You can edit at full-resolution, and then export to your desired frame size when complete--you'll probably still need to crop a few pixels (in the Export Settings window) to eliminate the black bars.

  • My icloud activation lock is ON my iphone, which requires an activation login to access the homescreen, but when i log in with the apple ID on the phone, it says the apple ID is not meant to unclock this iphone 5 ios 8.0.2. please help me solve this.

    My icloud activation lock is on my iphone, which requires an activation login to access the homescreen, but when i log in with the apple ID on the phone, it says the apple ID is not meant to unclock this iphone 5 ios 8.0.2. please help me solve this.

    Yes the phone belongs to me. It was purchased from United Kingdom Vodafone to West Africa, i had to factory unlock to use any sim in it. so it belongs to me. I did the activation myself, now after updating my iphone to the latest update, it required a user id and password to activate the phone, but anytime i enter the details, it tells me the user Id is not correct but the password is correct..

  • My imac stops(freezes) everytime when I try to extract ipod nano. So if I quit the connection by force, it stops again. Have no choice but to shut down the imac pushing power supply button. Pls help me solve out this problems.

    My imac stops everytime when I try to extract ipod nano. So if I do it by force it freezes agian. Have no choice but to shut down the computer
    by pushing power button. Pleas help me solve this out!!!
    It's not good to shut off the power forcibly, right? (I dun know what else I can do...)

    Hi Min! I'm having exactly the same issue - have been putting up with it now for months but have finally had enough! Every single time i eject either my iphone, ipad or ipod nano, itunes freezes up, the computer becomes unresponsive. Usually i can use the mouse to highlight icons but the system doesn't respond, the keyboard doesn't work and I have to do a hard reset.
    Arrrrrggggggh!!!!!!! lol
    Someone please help!!!

  • Calendar and Time showing in arabic but my phone's language is English. I bought my phone from DU in UAE , Dubai. Please help me solve this issue while keeping the Region to United Arab Emirates

    Calendar and Time showing in arabic but my phone's language is English. I bought my phone from DU in UAE , Dubai. Please help me solve this issue while keeping the Region to United Arab Emirates

    Valentine350z wrote:
    while keeping the Region to United Arab Emirates
    Not possible, I think.  Tell Apple how you feel about this at
    http://www.apple.com/feedback/iphone.html

  • I have problem with daq..when it is connected with laptop it asks for all the options like sampling rate etc..It displays building VI and it stops..it is not processing further..cau u plz help to solve this problem

    i hav problem with daq initialisation...plz help to solve the above mentioned issue

    Hi muthu,
    we also have a problem: to less information…
    - What is connected to your laptop?
    - What is "it" in "it displays building VI"? Do you use the DAQ Assistent ExpressVI?
    - What means "plz"?
    And could you please put less text in the title of your message and more text (with relevant information) into the message body?
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Capturing  through Sony HDV using firewire800 to 400 adaptor is not recognizing can any body help me solve this

    I am trying to capture using firewire 800 to 400 adaptor through a Sony HDV VTR. The VTR is not recognizing can some body help me solve this problem.
    I am using FCP7 and IMAC with 10.6.8 version os
    I dont have a 6 pin or 400 firewire port in the system

    Let's start with basics.
    Does your computer recognize that there is a VTR attached?
    • Open up system profiler>Hardware>FireWire.  Does your machine show up?
    If no, you need to figure out if the problem lies with the VTR, the cable, the adapter or your computer.
    My guess is with the adapter. A number of people have expressed frustration getting fw400 device to work through fw800 ports.
    If that's your problem, see if you can find an older Mac w/ fw400 ports or a dedicated fw800 to 400 cable.
    good luck,
    x
    ps - In "locking the barn after the paddle has been lost upstream" mode, this is why non-expandable computers like the iMac are so problematic. A MacBookPro with the expresscard 34 slot or a MacPro with 3 slots can work around these kind of issues. A closed box like the iMac is a dead end. Sorry.

  • Plz help me solving following issues

    Hi SD experts,
    Plz help me solving following issues
    1) What do you mean by POD(proof of delivery) what is the use of pod? What are the con figuration you done in your project?
    2) When I am punching order after entering data like material No and quantity system should pop-up a screen of delivery date and status and invoice data and details, How can we configure this?
    3) Client requirement is he want horizon period in days format. but standard sap system It's in months format(gray mode). how can we change months to days?
    4) Quotation has been created for product-D, 10 quantities, sales order is created with reference to the quotation, system copies 10 quantities in sales order. How do you restrict in sales order end user should not change quantities, system should not allow for changes by en user?
    5)  when i creating the sales order the system show error "No customer master record exist for sold to party". How to rectify it?
    suitable solutions will be rewarded
    thansx & regards

    hi,
    Proof of delivery (POD) is an instrument involved in business processes in which an invoice is issued only after the customer has confirmed the delivery's arrival. In addition to the proof of delivery itself, you can also record the POD date, POD time, the actual quantity that arrived and the reason for possible differences in quantities. This is especially important for deliveries where the delivery quantity varies because of the nature of the goods or for which the exact delivery quantity is unknown from the start.
    You are now in a position to issue an accurate invoice based on the customer's confirmation of goods received. You no longer need to create credit memos. The reasons for deviation that occur most frequently in "real world" scenarios such as stock shrinkage, theft, certain characteristics of goods (volatility, for example), and transportation damage are recorded and analyzed in the system. This analysis is especially valuable when you are negotiating with forwarding agents, vendors, or customers, since all deviations can be reflected
    With regards
    Rajesh

  • I updated my Iphone 4s to IOS 7, now it reboots after every 2 minutes, I tried to restore, but the reboot gets it disconnected from PC, help me solve this reboot issue..

    I updated my Iphone 4s to IOS 7, now it reboots after every 2 minutes, I tried to restore, but the reboot gets it disconnected from PC, help me solve this reboot issue..

    See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...
    Be sure to Follow ALL the Steps...
    But... if the Device has been Modified... this will Not necessarily work.

Maybe you are looking for

  • Problem with module lazy loading in flex 3

    Hi every body! I have some problems with Module lazy loading. I am using flex 3.5, Module-flex3-0.14, parsley 3.2. I can't get the LazyModuleLoadPolicy working correctly. In my main application (the one that loads the modules), my parsley context is

  • Using a second computer when the first takes a dive

    I need serious help....simply put: My original computer died on me and I cant seem to get any of my info from itunes or download my library off my nano....any ideas??? I know someone has had to have been through this before.

  • TopLink deployment problem

    Hi I have an application using TopLink. In my development environment, i am able to access the SessionFacadeBean, directly. This is, i can do a new SessionFacadeBean(), and i get the facade and can freely invoke their methods and routines However, i

  • Final Cut Pro X, Export to Youtube fail says, QuickTime Error: -50

    Im having trouble with Final Cut Pro X every time I try to export my project to Youtube a quarter way through processing it stops and says QuickTime Error: -50  How do I fix this?

  • Hi regarding a important question.

    I have got the design requirements with only field name with table names and remaining part of datsource to reports we have to generate by BW person., I am not sure functional guy gives specs to design datasource from what tables shall come., Can any