Changes between Version 1 and Version 2 of AdvancedReport24


Ignore:
Timestamp:
12/29/25 20:13:42 (5 days ago)
Author:
211101
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReport24

    v1 v2  
    1 ===== Неактивни тагови
     1==== Неактивни тагови
    22Идентификување тагови кои не биле користени во изминатиот месец
    33{{{#!sql
    4 SELECT
    5     tg.tag_name
    6 FROM
    7     tag tg
    8 LEFT JOIN tag_assigned_to_transaction tat ON tg.tag_id = tat.tag_id
    9 LEFT JOIN transaction t ON tat.transaction_id = t.transaction_id
    10 WHERE
    11     t.date IS NULL OR t.date < NOW() - INTERVAL '1 MONTH';
     4CREATE OR REPLACE FUNCTION get_inactive_tags_last_month()
     5RETURNS TABLE (
     6    tag_name TEXT
     7)
     8LANGUAGE plpgsql
     9AS $$
     10BEGIN
     11    RETURN QUERY
     12    SELECT
     13        tg.tag_name
     14    FROM tag tg
     15    LEFT JOIN tag_assigned_to_transaction tat
     16        ON tg.tag_id = tat.tag_id
     17    LEFT JOIN transaction t
     18        ON tat.transaction_id = t.transaction_id
     19    WHERE t.date IS NULL OR t.date < NOW() - INTERVAL '1 MONTH';
     20END;
     21$$;
    1222}}}
     23
     24==== Релациона алгебра
     25- TG(tag_id, tag_name)
     26- TAT(tag_id, transaction_id)
     27- T(transaction_id, date)
     28
     29LEFT JOIN на табелите:
     30- J1 ← TG ⟕,,TG.tag_id = TAT.tag_id,, TAT
     31- J2 ← J1 ⟕,,TAT.transaction_id = T.transaction_id,, T
     32
     33Филтрирање на неактивни тагови:
     34- R_final ← σ,,date IS NULL ∨ date < NOW() - INTERVAL '1 MONTH',,(J2)