Problem : Max can not return max value from varchar type field.

Problem : Max can not return max value from varchar type field.

ELOQUENT Query : $maxLicence = Agency::where('is_approved',1)->max('license_no');
RAW SQL Query : select max(test_value) from area_info;

Solution : 
$maxLicence = DB::select("select max(cast(agencys.license_no as int)) as license from agencys");

Comments

Popular posts from this blog

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine