IBM SQL Interview Question | Using CTEs

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

ความคิดเห็น • 9

  • @nirmalaswain4598
    @nirmalaswain4598 หลายเดือนก่อน

    thank you mam for such a great kind kind of seriese please continue this section

  • @harshitsalecha221
    @harshitsalecha221 หลายเดือนก่อน +4

    SELECT employee_id, first_name, job_category
    FROM (SELECT employee_id,
    first_name,
    job_category,
    DENSE_RANK() OVER(PARTITION BY job_category ORDER BY salary DESC) as rn FROM employees) as a
    WHERE rn=3;

  • @mohanbharadwaj7684
    @mohanbharadwaj7684 หลายเดือนก่อน +2

    which is more optimized query. Subquery or CTE's

    • @DevaSivaNagaSai
      @DevaSivaNagaSai หลายเดือนก่อน +1

      cte is more efficient than sub query

  • @badrilalnagar9232
    @badrilalnagar9232 หลายเดือนก่อน +1

    The family system of India is the basic source of Indian culture.

  • @saikirant4677
    @saikirant4677 หลายเดือนก่อน

    clearly explained

  • @echodelta7680
    @echodelta7680 หลายเดือนก่อน

    Hi Nishtha,
    1. If there are more than 1 employee in each dept. having same salary as third highest salary, then what result would your query return?
    2. Say, there is a table TRANSACTION having two columns ID and BILL. Table has 100 records, with IDs repeated many times, each ID having different or same bills. Here's a SELECT query to find the avg. bill for each ID over the table :
    SELECT ID, AVG(BILL) FROM TRANSACTION GROUP BY ID;
    My question is, does the AVG function run 100 x 100 times, top to bottom scanning one ID at a time? Note that I am not asking about the order of query execution (I know the order). I'm asking how these functions operate on the table rows in the background.

  • @HARSHRAJ-gp6ve
    @HARSHRAJ-gp6ve หลายเดือนก่อน

    simple dense rank question
    with cte as(
    select employees.*,DENSE_RANK()OVER(PARTITION BY job_category ORDER BY salary DESC) as x1 FROM employees
    )
    select employee_id,first_name,job_category FROM cte where x1=3;

  • @theinsightminer08
    @theinsightminer08 6 วันที่ผ่านมา

    SELECT
    employee_id,
    first_name,
    job_category
    FROM
    (SELECT
    *,
    DENSE_RANK() OVER(PARTITION BY job_category ORDER BY salary DESC) as rnk
    FROM employees) as Ranking
    WHERE rnk = 3
    ORDER BY employee_id;