Reputation: 5
Check the code below:
$this->set('hi', $this->posts->find('all',
array('fields'=>array('DISTINCT year(posts.Post_date)'))));
I am not getting the correct results ... can anyone help me in this please...
my query is (Select distinct year(post_date) from posts);
Thanks
Upvotes: 1
Views: 612
Reputation: 2540
replace below
`DISTINCT year(posts.Post_date)`
with below:-
YEAR(DISTINCT posts.Post_date) as year
Upvotes: 3