List:Spanish« Previous MessageNext Message »
From:Juan Vallini Date:July 30 2012 7:54pm
Subject:Re: Consulta
View as plain text  
Ok, lo que pasa que


----- Original Message ----- 
From: "Yanis Guenane" <yguenane@stripped>
To: "Juan Vallini" <Juan_Vallini@stripped>
Cc: <mysql-es@stripped>
Sent: Monday, July 30, 2012 4:50 PM
Subject: Re: Consulta


> Perdona mi espanol, intente traducirlo del ingles.
>
> Queria decir "obligatorio".
>
> On Mon, Jul 30, 2012 at 9:47 PM, Juan Vallini 
> <Juan_Vallini@stripped>wrote:
>
>> Yanis:
>>
>>    Perdona mi ignorancia, que seria Mandatorio.
>>
>> Saludos
>> ----- Original Message ----- From: "Yanis Guenane" <yguenane@stripped>
>> To: "Juan Vallini" <Juan_Vallini@stripped>
>> Cc: <mysql-es@stripped>
>> Sent: Monday, July 30, 2012 4:42 PM
>> Subject: Re: Consulta
>>
>>
>>  Depende de si el GROUP BY IDTipoReserva es mandatorio para ti. Si lo es,
>>> es
>>> impossible hacer lo que tu quieres.
>>>
>>> Sino
>>>
>>> SELECT
>>>  IDViajes,
>>>  COUNT(IF(IDTipoReserva = 1, IDViajesDetalle, 0)) as Confirmado,
>>>  COUNT(IF(IDTipoReserva = 2, IDViajesDetalle, 0)) as Condicional,
>>>  COUNT(IF(IDTipoReserva = 3, IDViajesDetalle, 0)) as Cancelado
>>> FROM Viajesdetalle
>>> WHERE (IDViajes = 7)
>>> GROUP BY IDViajes;
>>>
>>> deberia funcionar.
>>>
>>> Un saludo,
>>>
>>>
>>> 2012/7/30 Juan Vallini <Juan_Vallini@stripped>
>>>
>>>  Buenas:
>>>>
>>>>     Quisiera saber si pueddo dejar esta consulta en un solo registro y 
>>>> no
>>>> en tres:
>>>>
>>>> SELECT
>>>>   IDViajes,
>>>>   IF(IDTipoReserva = 1,COUNT(IDViajesDetalle),0) as Confirmado,
>>>>   IF(IDTipoReserva = 2,COUNT(IDViajesDetalle),0) as Condicional,
>>>>   IF(IDTipoReserva = 3,COUNT(IDViajesDetalle),0) as Cancelado
>>>> FROM Viajesdetalle
>>>> WHERE (IDViajes = 7)
>>>> GROUP BY IDViajes,IDTipoReserva;
>>>>
>>>> Este es el resultado.
>>>>       IDViajes Confirmado Condicional Cancelado
>>>>       7 1 0 0
>>>>       7 0 1 0
>>>>       7 0 0 1
>>>>
>>>>
>>>>
>>>> Quisiera que quede asi:
>>>>       IDViajes Confirmado Condicional Cancelado
>>>>       7 1 1 1
>>>>
>>>>
>>>>
>>>>       Gracias, espero haber sido claro.
>>>>
>>>>       SALUDOS
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> *Yanis Guenane*
>>>
>>>
>>
>
>
> -- 
> *Yanis Guenane*
> 

Thread
ConsultaJuan Vallini30 Jul
  • Re: ConsultaYanis Guenane30 Jul
  • Re: ConsultaJuan Vallini30 Jul
    • Re: ConsultaYanis Guenane30 Jul
  • Re: ConsultaJuan Vallini30 Jul
  • Re: ConsultaJuan Vallini30 Jul
    • Re: ConsultaYanis Guenane30 Jul