This query works. Do I need to use "LET" for any group by operations?
Thanks
On Thursday, August 7, 2014 4:36:37 AM UTC-7, Lvc@ wrote:
>
> Can you try:
>
> SELECT
> $yearAlias,
> $monthAlias,
> $dayAlias,
> $hourAlias,
> sum(sSize) AS totalsize
> LET
> $yearAlias = createdDate.format('yyyy'),
> $monthAlias = createdDate.format('MM'),
> $dayAlias = createdDate.format('dd'),
> $hourAlias = createdDate.format('HH')
> FROM Sample
> GROUP BY $yearAlias, $monthAlias, $dayAlias, $hourAlias
>
>
> Lvc@
>
>
> On 7 August 2014 02:58, moksh n <[email protected] <javascript:>> wrote:
>
>> Class with the following data
>>
>> createdDate - Datetime ( date pattern yyyy-MM-dd'T'HH:mm:ss.SSSZ)
>> size - Integer
>>
>> I've 6 records with each of size 1000 and varying hours.
>> Since I'm grouping at hour. I was expecting 6 records in results instead
>> I'm getting a single record accumulated on the last record.
>>
>> CreatedDate size
>>
>> 2014-08-06T18:53:06.858-0700 1000
>> 2014-08-06T19:53:06.858-0700 1000
>> 2014-08-06T19:53:07.358-0700 1000
>> 2014-08-06T20:53:07.358-0700 1000
>> 2014-08-06T20:53:07.358-0700 1000
>> 2014-08-06T17:53:07.358-0700 1000
>>
>> SELECT createdDate.format('yyyy') AS yearAlias,createdDate.format('MM')
>> AS monthAlias,createdDate.format('dd') AS dayAlias,createdDate.format('HH')
>> AS hourAlias,sum(sSize) AS totalsize FROM Sample GROUP BY
>> yearAlias,monthAlias,dayAlias,hourAlias
>>
>> results:[{yearAlias=2014, monthAlias=08, dayAlias=06,
>> hourAlias=17,totalsize=6000}]
>>
>> Thanks
>>
>>
>> On Tuesday, August 5, 2014 4:01:25 PM UTC-7, moksh n wrote:
>>>
>>> Using orient 1.7.7
>>> Thanks
>>>
>>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "OrientDB" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.