Results 1 to 5 of 5

Thread: Sql Coding Help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Jun 2008
    Answers
    3

    Re: Sql Coding Help

    Thanks for your reply.

    My requirements are:
    Enter the Date Parameter [From and To] for DateTimeCreated. If anyone's salary has changes in the date range, then display new rate / salary and pcik up the record before with old sal/rate.

    Can I UNION 2 sets of data - one with new rate / salary where isratechange = y and one with MAX(dateTimeCreated)? But with the second set of data i am not sure how NOT to capture the record where the salary was changed!

    Any thoughts, thanks
    Sony









    Quote Originally Posted by krishnaindia2007 View Post
    Information provided by you is not enough to write entire procedure.

    Based upon the output provided by you I assume that only some of the employees are having both old and new salaries.

    In that case first identify the list of those employees who salary is revised.








    Cursor v_cur is
    SELECT ejheeid
    FROM dbo.emphjob
    WHERE IsRateChange = 'Y'

    Open another and pass this ejheeid as parameter to new cursor.
    Capture old and new salaries based on isratechange flag.
    IsRateChange flag 'N' - old salary
    IsRateChange flag 'Y' - new salary


    Regards
    Krishna



  2. #2
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Sql Coding Help

    >>But with the second set of data i am not sure how NOT to capture the record where the salary was changed!

    To solve this problem first write a cursor to identify employee id's whose salray was changed.

    Cursor v_cur is
    SELECT ejheeid
    FROM dbo.emphjob
    WHERE IsRateChange = 'Y'
    AND DateTimeCreated between fromdate and todate



    Can I UNION 2 sets of data - one with new rate / salary where isratechange = y and one with MAX(dateTimeCreated)?

    You can use union.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact