2009年7月30日星期四

Re: [fw-db] DISTINCT SQL Statement

Dear Andrew,

Thank you for the tip. It works like a charm.

Thanks a lot

2009/7/30 Andrew Ballard <aballard@gmail.com>


CEHTURK wrote:
>
> Hello all
>
> How can I run this query? I have been struggeling for hours.
>
> SELECT COUNT(DISTINCT(CIN_Number)) as NumberofCases, MMT_Number as
> NumberOfCase  FROM material
>
>

It needs a GROUP BY clause in any case, but how are you trying to run it?
Using Zend_Db_Select?

       $select = $db->select()
           ->from('material',
                array(
                    'NumberOfCases' => new Zend_Db_Expr('COUNT(DISTINCT
CIN_Number)'),
                    'MMT_Number'
                ))
           ->group('MMT_Number');


Andrew
--
View this message in context: http://www.nabble.com/DISTINCT-SQL-Statement-tp24738814p24739770.html
Sent from the Zend DB mailing list archive at Nabble.com.




--

Erdal YAZICIOGLU
System & Network Engineer
Page Europa S.R.L - General Dynamics
www.pageuropa.it
Office - Rome : +39 0650395292
Mobile -Rome : +39 3490787196
Mobile -Istanbul: +90 536 3447989

没有评论: