0

Is there some kind of WITH expression in SQlite?

For example I'm trying to do (not working)

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
Dmitry
  • 581
  • 2
  • 8
  • 20

0 Answers0