iwanttobepowerful commented on PR #4619:
URL: https://github.com/apache/calcite/pull/4619#issuecomment-3558057731

   ```sql
   WITH 
     dept(dname, deptno, loc) AS (
    VALUES 
      ('ACCOUNTING', 10, 'NEW YORK'),
      ('RESEARCH', 20, 'DALLAS'),
      ('SALES', 30, 'CHICAGO'),
      ('OPERATIONS', 40, 'BOSTON')
     ),
     emp(empno, ename, job, mgr, hiredate, sal, comm, deptno) AS (
    VALUES 
      (7369, 'SMITH', 'CLERK', 7902, '1980-12-17'::date, 800.00, NULL::numeric, 
20),
      (7499, 'ALLEN', 'SALESMAN', 7698, '1981-02-20'::date, 1600.00, 300.00, 
30),
      (7521, 'WARD', 'SALESMAN', 7698, '1981-02-22'::date, 1250.00, 500.00, 30),
      (7566, 'JONES', 'MANAGER', 7839, '1981-02-04'::date, 2975.00, NULL, 20),
      (7654, 'MARTIN', 'SALESMAN', 7698, '1981-09-28'::date, 1250.00, 1400.00, 
30),
      (7698, 'BLAKE', 'MANAGER', 7839, '1981-01-05'::date, 2850.00, NULL, 30),
      (7782, 'CLARK', 'MANAGER', 7839, '1981-06-09'::date, 2450.00, NULL, 10),
      (7788, 'SCOTT', 'ANALYST', 7566, '1987-04-19'::date, 3000.00, NULL, 20),
      (7839, 'KING', 'PRESIDENT', NULL, '1981-11-17'::date, 5000.00, NULL, 10),
      (7844, 'TURNER', 'SALESMAN', 7698, '1981-09-08'::date, 1500.00, 0.00, 30),
      (7876, 'ADAMS', 'CLERK', 7788, '1987-05-23'::date, 1100.00, NULL, 20),
      (7900, 'JAMES', 'CLERK', 7698, '1981-12-03'::date, 950.00, NULL, 30),
      (7902, 'FORD', 'ANALYST', 7566, '1981-12-03'::date, 3000.00, NULL, 20),
      (7934, 'MILLER', 'CLERK', 7782, '1982-01-23'::date, 1300.00, NULL, 10)
     ),
     bonus(ENAME, JOB, SAL, COMM) AS (
    VALUES 
    ('ALLEN', 'SALESMAN', 1600.00, 300.00),
    ('WARD', 'SALESMAN', 1250.00, 500.00)
     )
   select count(*) as c
   from emp as e
   where sal + 100 not in (
     select deptno
     from dept
     where dname = e.ename);
   ```
   Input the above SQL statement into [umbra-db 
interface](https://umbra-db.com/interface/), click Execute, and check the 
optimization steps one by one. I believe it will be an excellent reference for 
us.
   <img width="1429" height="638" alt="Clipboard_Screenshot_1763644354" 
src="https://github.com/user-attachments/assets/4c568800-8c19-4954-9e24-d51ed182af68";
 />
   <img width="657" height="500" alt="Clipboard_Screenshot_1763645122" 
src="https://github.com/user-attachments/assets/f341fee4-993f-49eb-987f-0feb2f5d9722";
 />
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to