We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  • Hiring developers?
  1. Practice
  2. SQL
  3. Basic Select
  4. Employee Salaries
  5. Discussions

Employee Salaries

  • Problem
  • Submissions
  • Leaderboard
  • Discussions

    You are viewing a single comment's thread. Return to all comments →

  • RodneyShag 3 years ago+ 8 comments

    MySQL solution

    From my HackerRank solutions.

    SELECT name FROM Employee
    WHERE salary > 2000 AND months < 10
    ORDER BY employee_id;
    

    Let me know if you have any questions.

    11|
    Permalink
    • ranadipanshu938 3 years ago+ 1 comment

      question says salary should be greater than 2000 PER MONTH. your query check if it is greater than 2000 or not . explain please.

      -4|
      ParentPermalink
      • RodneyShag 3 years ago+ 0 comments

        "salary is the their monthly salary" as it says in the problem.

        HackerRank solutions.

        2|
        ParentPermalink
    • Akshita_Sood 2 years ago+ 3 comments

      Why does it give wrong answer if I use HAVING clause instead of WHERE clause?

      0|
      ParentPermalink
      • RodneyShag 2 years ago+ 0 comments

        paste your code here and we can take a look.

        0|
        ParentPermalink
      • phani_g19 2 years ago+ 0 comments

        hope ur code is like "select name,salary,months from employee having salary >2000 and months < 10 order by employee_id;" sal,months are not expected in output.

        0|
        ParentPermalink
      • 2digantkaushik 1 year ago+ 0 comments

        HAVING is used with GROUP BY and not ORDER BY. In the question you have been asked to sort according to the employee_id. This can be done by using ORDER BY.

        1|
        ParentPermalink
    • BansheeGhoul 2 years ago+ 0 comments

      Oracle :

      SELECT name FROM Employee WHERE salary > 2000 and months< 10 ORDER BY employee_id asc;

      0|
      ParentPermalink
    • 15KD1A05B7CSEB 2 years ago+ 0 comments
      [deleted]
      0|
      ParentPermalink
    • sbouzel 2 years ago+ 0 comments

      Other with MS SQL Server, I don't think you can order by employee_id if employee_id is not in you select!

      0|
      ParentPermalink
    • rahulmu4our 2 years ago+ 3 comments

      This is my MySQL Query:-

      SELECT name
      FROM Employee
      WHERE months < 10 
        AND salary > 2000;
      

      shall we need to add command "ORDER BY employee_id" here. by default table itself, data is displayed in order of Employee ID. Not only that, it does't mention in question also.

      0|
      ParentPermalink
      • knightofcode 2 years ago+ 0 comments

        yes your query does pass the testcase

        0|
        ParentPermalink
      • RodneyShag 2 years ago+ 0 comments

        The question states to " Sort your result by ascending employee_id".

        HackerRank solutions.

        2|
        ParentPermalink
      • kartikrayaprolu1 2 years ago+ 0 comments

        We need to add "Order By employee_id" because it is specified that we need ascending order.

        1|
        ParentPermalink
    • tayyabjsr13 8 months ago+ 1 comment

      What if months = 9 and salary = 9000

      0|
      ParentPermalink
      • RodneyShag 8 months ago+ 0 comments

        The line salary > 2000 AND months < 10 will match that (as in it will be true)

        HackerRank solutions.

        0|
        ParentPermalink
    • bumperlogos 8 months ago+ 0 comments

      The question asks to order employee id ascending. ORDER BY employee_id ASC;

      ASC = Ascending DESC = Descending

      0|
      ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature