IIRC, there IS a case in HQL.

On Fri, Dec 5, 2008 at 1:52 PM, Markus Zywitza <[EMAIL PROTECTED]>wrote:

> AFAIK there is no CASE in HQL. But since you're querying values, not
> objects, I'd rather go for a SQL query in your case.
>
> -Markus
> 2008/12/4 M Kenyon II <[EMAIL PROTECTED]>
>
>
>> I am doing a report that sums hours for several employees, based on a
>> grouping per week. I want to find how much overtime is being spent.
>> So, I want 2 values, a sum of all time, and a sum of just the
>> overtime.
>>
>> I was thinking of doing a case statement, like in SQL, but I'm not
>> sure how to do it in active record.
>>
>> I currently have a query like this:
>> ClassificationRequest.Append(@"
>>                                        select
>>                                                        trn.Week,
>>                                                        
>> dtl.Section.ID<http://dtl.section.id/>
>> ,
>>                                                        
>> dtl.Category.ID<http://dtl.category.id/>
>> ,
>>                                                        sum(dtl.Hours),
>>                            year(trn.Date)
>>                                        from    TransactionDetail dtl
>>                                                        inner join
>> dtl.Transaction trn
>>                                                        inner join
>> trn.Badge bdg
>>                                                        inner join
>> bdg.District dst
>>                                        where
>>
>> bdg.Classification.ID <http://bdg.classification.id/> = :ID");
>>                if (region > 0)
>>                {
>>                    ClassificationRequest.Append(@"
>>                            and dst.Region.ID <http://dst.region.id/> =
>> :RegID
>>                    ");
>>                }
>>                if (district > 0)
>>                {
>>                    ClassificationRequest.Append(@"
>>                            and dst.ID = :DistID
>>                    ");
>>                }
>>
>>
>>                ClassificationRequest.Append(@" and
>>                            trn.Date between :start AND :end
>>                                        group by
>>                                                        
>> dtl.Category.ID<http://dtl.category.id/>
>> ,
>>                                                        trn.Week,
>>                            
>> bdg.Classification.ID<http://bdg.classification.id/>
>> ,
>>                                                        
>> dtl.Section.ID<http://dtl.section.id/>
>> ,
>>                                                        trn.Date
>>                                ");
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to