Changes between Initial Version and Version 1 of AdvancedReport2


Ignore:
Timestamp:
12/28/25 23:13:08 (5 days ago)
Author:
211101
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReport2

    v1 v1  
     1===== Надминување на баланс на една сметка со трансакција во сегашно време
     2{{{#!sql
     3CREATE OR REPLACE FUNCTION get_current_account_overdrafts()
     4RETURNS TABLE (
     5    user_id INT,
     6    user_name TEXT,
     7    account_name TEXT,
     8    current_balance NUMERIC,
     9    transaction_id INT,
     10    transaction_name TEXT,
     11    transaction_amount NUMERIC,
     12    transaction_date TIMESTAMP
     13)
     14LANGUAGE plpgsql
     15AS $$
     16BEGIN
     17    RETURN QUERY
     18    SELECT
     19        u.user_id,
     20        u.user_name,
     21        ta.account_name,
     22        ta.balance,
     23        t.transaction_id,
     24        t.transaction_name,
     25        tb.spent_amount,
     26        t.date
     27    FROM transaction_account ta
     28    JOIN "user" u ON ta.user_id = u.user_id
     29    JOIN transaction_breakdown tb ON ta.transaction_account_id = tb.transaction_account_id
     30    JOIN transaction t ON tb.transaction_id = t.transaction_id
     31    WHERE tb.spent_amount > ta.balance
     32      AND tb.spent_amount > 0
     33    ORDER BY t.date DESC;
     34END;
     35$$;
     36}}}