query builder

hi all i have used the below query


  $sql = Yii::app()->db->createCommand()

     		->select('sum(Demand_amount),Demand_due')

			->from('tbl_charges_demand_details')

            ->where('Demand_flat_number=:Demand_flat_number and Demand_paid_flag=:dstatus ', array(':Demand_flat_number'=>$model->flatnumber,':dstatus'=>'n'))

            ->group(array('Demand_due'))

			->queryColumn();

now i want to use the Demand_due in for loop so how to use it.i tried with $sql[‘Demand_due’] but couldnt succeed.plz help me]

thanks

ramakrishna

try to use


queryAll()

method not


queryColumn()

.

queryColumn() retruns first column of the result.