Description: Write a query to find the month number (Eg: 4 corresponds to April) in which the most number of payments were made.
Sample Output
Hi,
Try this out to convert string month name to month number and get the max value out of a column
select date_format(str_to_date(Month,'%M'),'%c') as Payment_month, MAX(Payments_Made) as No_of_payments from payment_details;
Correct answer:
SELECT EXTRACT(MONTH FROM payment_date) AS Payment_month, COUNT(*) as No_of_payments FROM payment GROUP BY Payment_month ORDER BY COUNT(*) DESC LIMIT 1;
Most Productive Month
Description: Write a query to find the month number (Eg: 4 corresponds to April) in which the most number of payments were made.
Sample Output