Hi
I have the following query, but it seems inner selects take much longer to execute.
Is there a better way with joins to write this?
SELECT @group := c.`group name`as 'Group Name',
(select companyname(@group)),
(select sum(umbrella_premium+pensioner_premium+seniorplan_premium) from schedule_premiums where `group name` = @group ) as 'Premium Receivable',
(select sum(money_received) from schedule_premiums where `group name` = @group ) as 'Premium Received'
FROM schedule_premiums a, activegroups c
where a.`group name` = c.`group name`
group by a.`group name`
I have the following query, but it seems inner selects take much longer to execute.
Is there a better way with joins to write this?
SELECT @group := c.`group name`as 'Group Name',
(select companyname(@group)),
(select sum(umbrella_premium+pensioner_premium+seniorplan_premium) from schedule_premiums where `group name` = @group ) as 'Premium Receivable',
(select sum(money_received) from schedule_premiums where `group name` = @group ) as 'Premium Received'
FROM schedule_premiums a, activegroups c
where a.`group name` = c.`group name`
group by a.`group name`