I am working with a slightly complex query where I have to count the number of times an year has come in the publication_date column. I am using the Query builder from laravel and doing something like:
$publication_years = Patent::whereIn('id', $ids)->select(DB::raw('publication_date, COUNT(YEAR(publication_date)) AS count'))->groupBy('publication_date')->get();
But this is not working. This is still using the whole date to check. How can I correct this? I have tried SUBSTR too and I also tried to convert it using CONVERT and CAST but in vain? Anyone has any idea?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire