source: database/Advanced Reports for database/List of reports which haven't been approved.txt@ 06ebe74

finki-main main
Last change on this file since 06ebe74 was 62b2964, checked in by Klimentina Efremova <klimentina08642@…>, 2 weeks ago

Project Handcraft Marketplace

  • Property mode set to 100644
File size: 532 bytes
Line 
1CREATE OR REPLACE FUNCTION get_unapproved_reports()
2RETURNS TABLE (
3 report_date DATE,
4 store_id INT,
5 overall_profit NUMERIC,
6 month_and_year TEXT,
7 profit NUMERIC
8)
9LANGUAGE plpgsql
10AS $$
11BEGIN
12 RETURN QUERY
13 SELECT
14 r.date AS report_date,
15 r.store_id,
16 r.overall_profit,
17 r.month_and_year,
18 r.profit
19 FROM report r
20 LEFT JOIN approves a
21 ON r.date = a.date
22 AND r.store_id = a.store_id
23 WHERE a.date IS NULL
24 ORDER BY
25 r.date DESC;
26END;
27$$;
Note: See TracBrowser for help on using the repository browser.