Changes between Initial Version and Version 1 of AdvancedReport12


Ignore:
Timestamp:
08/21/26 06:24:50 (29 hours ago)
Author:
235018
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReport12

    v1 v1  
     1= List of clients who haven't made an order
     2{{{#!sql
     3CREATE OR REPLACE FUNCTION get_clients_without_orders()
     4RETURNS TABLE (
     5    client_id INT,
     6    client_name TEXT,
     7    email TEXT
     8)
     9LANGUAGE plpgsql
     10AS $$
     11BEGIN
     12    RETURN QUERY
     13    SELECT
     14        c.client_id,
     15        c.name AS client_name,
     16        c.email
     17    FROM client c
     18    LEFT JOIN makes_order mo
     19        ON c.client_id = mo.client_id
     20    WHERE mo.order_num IS NULL
     21    ORDER BY c.client_id;
     22END;
     23$$;
     24}}}
     25
     26== Relational Algebra
     27- C(client_id, name, first_name, last_name, email, password, delivery_address)
     28- MO(client_id, order_num)
     29
     30**JOIN clients with their orders:**
     31- J1 ← C ⟕C.client_id = MO.client_id MO
     32
     33**SELECT only clients who aren't connected to any orders:**
     34- F1 ← σorder_num IS NULL(J1)
     35
     36**Sort by client ID:**
     37- R_final ← τclient_id ASC(F1)
     38
     39