Cisco Interview Question | Query I

Question
Emp_id Emp_name Manager_id Dept_id Joining_date Salary
1 Joy 0 Q 1 January, 2018 6000
2 Manu 0 5 5 July, 2019 6000
3 Ajay 1 1 13 August, 2017 2000
13 Akanksha 2 5 16 May,2020 2000
11 Surbhi 2 1 21 July, 2015 2000
9 Louise 1 5 September,2018 3000
8 Vishal 3 1 7 June, 2012 3500
7 Chen Lee 2 5 31 July,2018 NULL
3 Apoorva 1 1 29 February,2016 2000

Write a query to find employees who have completed more than 2 years in the company. Create a separate table containing Emp_id, salary and Joining date (in this order only)

(Hint- Let today be 31st July,2020)

in progress 0
Dhruv2301 55 years 2 Answers 991 views Great Grand Master 0

Answers ( 2 )

  1. create table emp_new as (
    select emp_id,joining_date, salary
    from employees
    where year(now()) – year(joining_date) >= 2
    order by joining_date)

  2. CREATE table emp_new as (
    SELECT emp_id,joining_date, salary
    FROM employees
    WHERE EXTRACT(YEAR FROM AGE(CURRENT_DATE, convert(date, joining_date ) ))>=2
    ORDER BY joining_date)

Leave an answer

Browse
Browse