Tema: Re: Microsoft SQL uzklausa
Autorius: a
Data: 2010-09-27 11:28:00
dėkui, viskas veikia :)

"2x50" <tlchj61@gmail.com> parašė naujienų 
news:i7pk73$9h4$1@trimpas.omnitel.net...
> principas (ne sitankse) toks
>
> select
>    date,
>    sum(case when success = 1 then 1 else null end) Ok,
>    sum(case when success = 0 then 1 else null end) Failed
> from
>    table
> group by
>    date
>
> Arba http://msdn.microsoft.com/en-us/library/ms177410.aspx
>
> "a" <a@a.lt> wrote in message news:i7picr$63c$1@trimpas.omnitel.net...
>> tarkim yra duomenys:
>>
>> [Date] [Success]
>>
>> 2010-09-24 15:33:59.000 0
>> 2010-09-24 15:34:13.000 0
>> 2010-09-25 16:45:15.000 1
>> 2010-09-25 17:08:12.000 0
>> 2010-09-26 15:52:23.000 0
>> 2010-09-26 16:52:45.000 1
>> 2010-09-26 19:53:37.000 1
>>
>> Kaip ištraukti tokius rezultatus per vieną užklausą:
>>
>> [Date]            Ok    Failed
>> 2010-09-24  0        2
>> 2010-09-25  1        1
>> 2010-09-26  2        1
>>
>>
>> būtų vienas stulpelis tai group by + convert(date, [Date])  + count'as. 
>> Count'as subselecto lyg ir nevalgo...
>
>