MySQL Forums
Forum List  »  Spanish

Contar cero cuando no exista registro indicado
Posted by: Monttanna Monttanna
Date: July 04, 2014 06:12PM

Hola colegas, estuve pensando como hacer un conteo en cero cuando no halla registro alguno en la tabla desde un SELECT, expongo ejemplo:

Tengo el siguiente Query condicionado:

SELECT Column1, COUNT(Column2) AS Qty FROM TablaA WHERE Column1 IN ('A','B','C') GROUP BY Column1;

digamos que si tengo en mi tabla varios registros a y b el, pero no tengo ninguno de c, la vista me lanza esto:

Column1--Qty
a---------5
b---------9

Que necesito cambiar para que aparezcan todos lo datos condicionados aun que no halla algún registro de ellos en tabla ,algo asi:

Column1--Qty
a---------5
b---------9
c---------0

Options: ReplyQuote


Subject
Views
Written By
Posted
Contar cero cuando no exista registro indicado
3488
July 04, 2014 06:12PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.