Quiero dividir dos resultados de dos consultos MySQL
SELECT `count_first_recurrent`/`count_initialization` FROM
SELECT count(distinct `orders`.`gxo_vads_subscription`) AS `count_first_recurrent`
FROM `orders`
WHERE (`orders`.`engagement` = 'R'
AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE'),
SELECT count(distinct `orders`.`gxo_vads_subscription`) AS `count_initialization`
FROM `orders`
WHERE (`orders`.`engagement` = 'M'
AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE')
En efecto cada uno de los inner select devuelven numeros y quiero dividirlos.
Por desgracia lo que intenté me devuelve:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT count(distinct `orders`.`gxo_vads_subscription`) AS `count_first_recurren' at line 3
Actualizacion
Con lo que me aconseja Srsole, intenté:
SELECT (count_first_recurrent/count_initialization) FROM
(
(SELECT count(distinct `orders`.`gxo_vads_subscription`) count_first_recurrent
FROM `orders`
WHERE `orders`.`engagement` = 'R'
AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE') as a,
(SELECT count(distinct `orders`.`gxo_vads_subscription`) count_initialization,
FROM `orders`
WHERE `orders`.`engagement` = 'M'
AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE') AS b
)
Pero me devuelve:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `orders` WHERE `orders`.`engagement` = 'M' AND `orders' at line 20