Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Sample for declarative grouping and sums still using old approach?

    Hi Isomorphic,

    I have the need to COUNT(*) from entries and I'm looking for the best way to do so.
    I read about "declarative grouping and sums" in your latest blog post (http://blog.isomorphic.com/new-smart...ures/#grouping), which links to this sample: sql_dynamic_reporting

    To me, the sample looks like it worked that way also in 4.0p and does not use the new features.

    Is this true, and if so, could you adapt it?

    Best regards,
    Blama

    #2
    As note for someone trying the same. I succeeded with:
    Code:
    	<fields>
    		<field name="LEAD_ID" type="integer" />
    		<field name="LEADCOUNT" type="integer" customSQL="true" nativeName="LEAD_ID" />	<operationBindings>
    		...
    	</fields>
    	<operationBindings>
    		<operationBinding operationType="fetch" requiresRole="serveronly" />
    		<operationBinding operationType="fetch" requiresRole="serveronly" operationId="countEntries">
    			<customFields>LEADCOUNT</customFields>
    			<summaryFunctions>
    				<LEADCOUNT>count</LEADCOUNT>
    			</summaryFunctions>
    		</operationBinding>
    		<operationBinding operationType="update" requiresRole="readonly" />
    	</operationBindings>
    
    
    Resulting SQL:
    SELECT COUNT (mytable.lead_id) AS leadcount
      FROM mytable
     WHERE (...)
    I used the LEADCOUNT as an extra field that is not output normally in order to get a meaningful name for the count.

    Best regards,
    Blama

    Comment

    Working...
    X