sql 报告de cuentas
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 报告de cuentas相关的知识,希望对你有一定的参考价值。
#### detallado #####
SELECT
a.appointment_id,a.created_dt,a.status,a.amount,a.payment_type, w.unique_id,wt.type_name
FROM appointment a
left join workplace w on a.car_id= w.workplace_id
left join workplace_types wt on w.type_id = wt.type_id
WHERE a.status in (9,4) AND
a.payment_type in (1,2,4) AND a.amount>0 AND
(
CASE
WHEN a.status = 9 and a.payment_type = 4 then a.payment_type != 4 and a.created_dt > '2018-10-29 00:00:00' AND a.created_dt < '2018-11-04 23:59:59'
WHEN a.status = 4 and a.payment_type = 2 THEN a.created_dt > '2018-10-29 00:00:00' AND a.created_dt < '2018-11-04 23:59:59'
WHEN a.status = 4 THEN (
(a.appointment_id) IN
(
select pp.appointment_id from pending_payment as pp
inner join slave_card_charge as scc
on pp.appointment_id=scc.appointment_id
where (scc.captured='true' or scc.captured=1) and pp.status=1 and
scc.created_date BETWEEN '2018-10-29 00:00:00' AND '2018-11-04 23:59:59'
)
or
(a.appointment_id) IN
(
SELECT swc.appointment_id FROM slave_wallet_charge as swc
inner JOIN pending_payment as pp on swc.appointment_id=pp.appointment_id
where pp.status=1 and
swc.created_date BETWEEN '2018-10-29 00:00:00' AND '2018-11-04 23:59:59'
)
or
(a.appointment_id) IN
(
select a.appointment_id from slave_card_charge as scc
where scc.appointment_id != 0 and a.appointment_id=scc.appointment_id and (scc.captured='true' or scc.captured=1)
and scc.created_date BETWEEN '2018-10-29 00:00:00' AND '2018-11-04 23:59:59'
)
)
else a.created_dt > '2018-10-29 00:00:00' AND a.created_dt < '2018-11-04 23:59:59'
END
)
###suma ####
SELECT SUM(amount) as suma, w.unique_id,wt.type_name FROM appointment a
left join workplace w on a.car_id = w.workplace_id
left join workplace_types wt on w.type_id = wt.type_id
WHERE a.status in (9,4) AND a.payment_type in (1,2,4) and a.amount>0 and
(
CASE
WHEN a.status = 9 and a.payment_type = 4 then a.payment_type != 4 and a.created_dt > '2018-10-29 00:00:00' AND a.created_dt < '2018-11-04 23:59:59'
WHEN a.status = 4 and a.payment_type = 2 THEN a.created_dt > '2018-10-29 00:00:00' AND a.created_dt < '2018-11-04 23:59:59'
WHEN a.status = 4 THEN (
(a.appointment_id) IN
(
select pp.appointment_id from pending_payment as pp
left join slave_card_charge as scc
on pp.appointment_id=scc.appointment_id
where (scc.captured='true' or scc.captured=1) and pp.status=1 and
scc.created_date BETWEEN '2018-10-29 00:00:00' AND '2018-11-04 23:59:59'
)
or
(a.appointment_id) IN
(
SELECT swc.appointment_id FROM slave_wallet_charge as swc
LEFT JOIN pending_payment as pp on swc.appointment_id=pp.appointment_id
where pp.status=1 and
swc.created_date BETWEEN '2018-10-29 00:00:00' AND '2018-11-04 23:59:59'
)
or
(a.appointment_id) IN
(
select a.appointment_id from slave_card_charge as scc
where scc.appointment_id != 0 and a.appointment_id=scc.appointment_id and (scc.captured='true' or scc.captured=1)
and scc.created_date BETWEEN '2018-10-29 00:00:00' AND '2018-11-04 23:59:59'
)
)
else a.created_dt > '2018-10-29 00:00:00' AND a.created_dt < '2018-11-04 23:59:59'
END
)
GROUP BY a.car_id
以上是关于sql 报告de cuentas的主要内容,如果未能解决你的问题,请参考以下文章
sql 报告pendiente de pago completado contabilidad
染料打样检测报告中的DE,DL,DC,DH,DA,DB分别代表啥?(注:检测软件是思维士软件)
sql SQL Anywhere:Mostrar Tablas y Campos de la Base de Datos