SQlite中是否有某种WITH
表达式?
例如,我试图做(不工作)
SELECT s.name AS 'service',
(SELECT value FROM payments WHERE (serviceId = s.id) AND (managerId = $managerId)) AS 'payment',
COUNT(s.name) AS 'amount',
('payment' * 'amount') AS summary //that is the point I want to optimise
FROM tickets t
JOIN services_to_tickets st ON t.id = st.ticketId
JOIN services s ON st.serviceId = s.id
JOIN medics m ON t.medicId = m.id
JOIN managers mg ON mg.id = m.managerId
WHERE mg.id = $managerId
GROUP BY service