回复: Re: GROUP BY month(date)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

回复: Re: GROUP BY month(date)

Lei Wu
Jacopo,

Sure, I'll test this new patch and let you know the results once it's done.

--
发自我的ONEPLUS智能手机

Jacopo Cappellato <[hidden email]>编写:

>It would be great if you could test this improved version of the patch that I sent you: it internally uses the EXTRACT function that should be a standard function since SQL-99.
>
>Thanks,
>
>Jacopo
>
>
>Index: framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java
>===================================================================
>--- framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (revision 1641394)
>+++ framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (working copy)
>@@ -65,6 +65,8 @@
>         functionPrefixMap.put("count-distinct", "COUNT(DISTINCT ");
>         functionPrefixMap.put("upper", "UPPER(");
>         functionPrefixMap.put("lower", "LOWER(");
>+        functionPrefixMap.put("year", "EXTRACT(YEAR FROM ");
>+        functionPrefixMap.put("month", "EXTRACT(MONTH FROM ");
>     }
>
>     /** Contains member-entity alias name definitions: key is alias, value is ModelMemberEntity */
>@@ -480,7 +482,7 @@
>                     fieldSet = alias.getFieldSet();
>                 }
>             }
>-            if ("count".equals(alias.function) || "count-distinct".equals(alias.function)) {
>+            if ("count".equals(alias.function) || "count-distinct".equals(alias.function) || "year".equals(alias.function) || "month".equals(alias.function)) {
>                 // if we have a "count" function we have to change the type
>                 type = "numeric";
>             }
>
>
>On Nov 18, 2014, at 11:40 AM, Jacopo Cappellato <[hidden email]> wrote:
>
>> Thanks for letting me know it worked for you.
>> I will commit it sometime soon if no one will object.
>>
>> Best regards,
>>
>> Jacopo
>>
>> On Nov 18, 2014, at 4:37 AM, [hidden email] wrote:
>>
>>> Dear Jacopo,
>>>
>>> Thanks so much for your kind help, the solution works perfectly as it is exactly what I wanted ! Now I can summary the total in the dimensions I want, i.e. MONTH and YEAR. Thanks so much again, and I also think it is helpful to commit these two added functions to public trunk in case others have similar requirements like mine.
>>>
>>> --
>>> 发自我的ONEPLUS智能手机
>>>
>>>
>>>
>>> Jacopo Cappellato <[hidden email]>编写:
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: GROUP BY month(date)

Jacopo Cappellato-4
Thank you!
It would be even better if you could test the latest patch I have attached to Jira:

https://issues.apache.org/jira/secure/attachment/12683398/OFBIZ-5146.patch

This last one also supports the "day" function.

Regards,

Jacopo

On Nov 25, 2014, at 4:56 AM, [hidden email] wrote:

> Jacopo,
>
> Sure, I'll test this new patch and let you know the results once it's done.
>
> --
> 发自我的ONEPLUS智能手机
>
>
>
> Jacopo Cappellato <[hidden email]>编写:
>