[ic] sql funtion (group by and count)

Mike Heins interchange-users@icdevgroup.org
Tue May 6 17:18:00 2003


Quoting Stefan Hornburg (Racke) (racke@linuxia.de):
> On Tue, 6 May 2003 22:08:48 +0200
> "Xavier GILLET" <xavier.gillet.perso@wanadoo.fr> wrote:
> 
> > hi,
> > 
> > Does anyone know how to use group by and count mysql functions in IC ?
> > This request groups column 'departement' and display the list, but
> > does not count the number of entries for each 'departement'.
> > 
> > [query sql="select departement, count(departement) from [scratch
> > this_page]
> >  where
> >  initial_status = 'confirmee'
> >  and
> >  actual_status = 'En ligne'
> >  and
> >  sens = 'Vente'
> >  group by departement"
> >         type=list]
> > [list]
> > [sql-param departement]<br>
> > [/list]
> > [/query]
> 
> The [query] tag groks any valid SQL statement if the underlying database
> is native SQL, but you might need to use [sql-pos] resp. [PREFIX-pos]
> to learn the results of it. In your example [sql-pos 1] would display
> the count.
> 

And with "select department, count(department) as deptcount ...." you
can use [sql-param deptcount].

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

Software axiom: Lack of speed kills.