Q:

using alias, condtional logic for criteria and nested criteria in grails/groovy

I am using the criteria api in my grails app like this
 def SummTblList  = ['TxnSummMon','TxnSummTue','TxnSummWed','TxnSummThu','TxnSummFri','TxnSummSat','TxnSummSun']
def res_row;

 SummTblList.each{
         res_row=it.createCriteria().list() {   

            eq('resource',resourceInstance)
            between('date', new Date()-31, new Date())        

            projections {  
            sum('actioncount')
            groupProperty 'location'         
                }                  
            }      

How do I use an Alias for sum('actioncount').. want to name it  t_count?
I have a case when resource is not selected ...basically that criteria should not be applied if selected_option is 'all' how do I create a conditional logic in criteria? or do I need to create to seperate criterias totally?
The goal here is thatI have 7 summary tables one for each day of the week and running the above query will give me all action counts for all locations in a date range. now I want to sum all the counts for all seven days of the week by location. so I should finally have a total of all action counts for all location for all days of the week, how do I create a criteria which returns this?

A:

According to this page, you should be able to do:
 sum 'actioncount', 't_count'

