Skip to main content
se añadió 1 carácter en el cuerpo
Origen Enlace

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 aconsejaSrsoleaconseja Srsole, intenté:

SELECT (`count_first_recurrent`count_first_recurrent/`count_initialization`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`) ) AS `count_first_recurrent`count_initialization,
        (FROM `orders`
        WHERE (`orders`.`engagement` = 'M'
           AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE')) AS `count_initialization`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 `order'`orders' at line 820

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 aconsejaSrsole, intenté:

SELECT (`count_first_recurrent`/`count_initialization`) FROM
    (
        (SELECT count(distinct `orders`.`gxo_vads_subscription`)
        FROM `orders`
        WHERE (`orders`.`engagement` = 'R'
           AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE'),
        SELECT count(distinct `orders`.`gxo_vads_subscription`) ) AS `count_first_recurrent`,
        (FROM `orders`
        WHERE (`orders`.`engagement` = 'M'
           AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE')) AS `count_initialization`
   )
   

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 `order' at line 8

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
se añadieron 893 caracteres en el cuerpo
Origen Enlace

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 aconsejaSrsole, intenté:

SELECT (`count_first_recurrent`/`count_initialization`) FROM
    (
        (SELECT count(distinct `orders`.`gxo_vads_subscription`)
        FROM `orders`
        WHERE (`orders`.`engagement` = 'R'
           AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE'),
        SELECT count(distinct `orders`.`gxo_vads_subscription`) ) AS `count_first_recurrent`,
        (FROM `orders`
        WHERE (`orders`.`engagement` = 'M'
           AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE')) AS `count_initialization`
   )
   

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 `order' at line 8

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
   

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 aconsejaSrsole, intenté:

SELECT (`count_first_recurrent`/`count_initialization`) FROM
    (
        (SELECT count(distinct `orders`.`gxo_vads_subscription`)
        FROM `orders`
        WHERE (`orders`.`engagement` = 'R'
           AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE'),
        SELECT count(distinct `orders`.`gxo_vads_subscription`) ) AS `count_first_recurrent`,
        (FROM `orders`
        WHERE (`orders`.`engagement` = 'M'
           AND `orders`.`status` = 2 AND `orders`.`gxo_means` = 'SE')) AS `count_initialization`
   )
   

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 `order' at line 8
Origen Enlace

Dividir dos SELECT

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