forked from brmlab/brmbar-github
USAGE: Fix pre within lists
This commit is contained in:
parent
11eaecfccf
commit
9a70088591
1 changed files with 19 additions and 19 deletions
|
@ -95,32 +95,32 @@ Useful SQL queries
|
||||||
|
|
||||||
* Compute sum of sold stock:
|
* Compute sum of sold stock:
|
||||||
|
|
||||||
select sum(amount) from transactions
|
select sum(amount) from transactions
|
||||||
left join transaction_splits on transaction_splits.transaction = transactions.id
|
left join transaction_splits on transaction_splits.transaction = transactions.id
|
||||||
where description like '% sale %' and side = 'debit';
|
where description like '% sale %' and side = 'debit';
|
||||||
|
|
||||||
* List of items not covered by inventory check:
|
* List of items not covered by inventory check:
|
||||||
|
|
||||||
select * from account_balances
|
select * from account_balances
|
||||||
where id not in (select account from transactions
|
where id not in (select account from transactions
|
||||||
left join transaction_splits on transaction_splits.transaction = transactions.id
|
left join transaction_splits on transaction_splits.transaction = transactions.id
|
||||||
where description like '% inventory %')
|
where description like '% inventory %')
|
||||||
and acctype = 'inventory';
|
and acctype = 'inventory';
|
||||||
|
|
||||||
* List all cash transactions:
|
* List all cash transactions:
|
||||||
|
|
||||||
select time, transactions.id, description, responsible, amount from transactions
|
select time, transactions.id, description, responsible, amount from transactions
|
||||||
left join transaction_splits on transaction_splits.transaction = transactions.id
|
left join transaction_splits on transaction_splits.transaction = transactions.id
|
||||||
where transaction_splits.account = 1;
|
where transaction_splits.account = 1;
|
||||||
|
|
||||||
* List all inventory items ordered by their cummulative worth:
|
* List all inventory items ordered by their cummulative worth:
|
||||||
|
|
||||||
select foo.*, foo.rate * -foo.crbalance as worth from
|
select foo.*, foo.rate * -foo.crbalance as worth from
|
||||||
(select account_balances.*,
|
(select account_balances.*,
|
||||||
(select exchange_rates.rate from exchange_rates, accounts
|
(select exchange_rates.rate from exchange_rates, accounts
|
||||||
where exchange_rates.target = accounts.currency
|
where exchange_rates.target = accounts.currency
|
||||||
and accounts.id = account_balances.id
|
and accounts.id = account_balances.id
|
||||||
order by exchange_rates.valid_since limit 1) as rate
|
order by exchange_rates.valid_since limit 1) as rate
|
||||||
from account_balances where account_balances.acctype = 'inventory')
|
from account_balances where account_balances.acctype = 'inventory')
|
||||||
as foo order by worth;
|
as foo order by worth;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue