roam/aweber/20220329103252-identifying_active_accounts.org

30 lines
1.1 KiB
Org Mode
Raw Normal View History

2022-03-30 13:52:04 +00:00
:PROPERTIES:
:ID: e97adcf4-86ad-4d97-9c63-41476b52b111
:END:
#+title: Identifying active accounts
A query to identify active accounts in [[id:dd113e53-6144-4cb2-a4aa-da3dc2e3e6ea][AppDB]]
Per [[file:~/git/appdb/functions/coreapi_account/get_account_status.yaml][coreapi_account.get_account_status]]:
#+begin_src sql :exports code :eval never
CREATE FUNCTION coreapi_account.get_account_status(in_account_id integer) RETURNS coreapi_account.account_status
LANGUAGE sql STRICT
AS $_$
SELECT accounts.status_id,
accounts.status_id = 7,
CASE accounts.status_id
WHEN 1 THEN 'New Order'
WHEN 4 THEN 'Unpaid - Un-notified'
WHEN 5 THEN 'Paid'
WHEN 6 THEN 'Unpaid - Notified'
WHEN 7 THEN 'Cancelled'
WHEN 8 THEN 'Unpaid - Overdue'
WHEN 9 THEN 'Place Holder'
ELSE 'Unknown'
END
FROM public.accounts
WHERE accounts.a_id = $1;
#+end_src