Guest User

Untitled

a guest
Apr 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.42 KB | None | 0 0
  1. $select = $this->getTable()
  2.     ->select()
  3.     ->from(
  4.         'property_stats',
  5.         array(
  6.             'stat_property_id',
  7.             'month' => 'MONTH(`stat_date`)',
  8.             'unique' => 'SUM(`stat_count_unique`)',
  9.             'returning' => 'SUM(`stat_count_returning`)'
  10.         )
  11.     )
  12.     ->joinLeft(
  13.         'property',
  14.         array('property_id = stat_property_id')
  15.     )
  16.     ->where('YEAR(`stat_date`) = YEAR(CURDATE())')
  17.     ->group('stat_property_id')
  18.     ->group('MONTH(`stat_date`)');
Add Comment
Please, Sign In to add comment