MySQL Forums
Forum List  »  Newbie

Re: Rows to Columns without duplicate rows
Posted by: Jassim Rahma
Date: July 02, 2021 12:09PM

I tried below but did not work

SELECT MONTHNAME(business_activity.created_date) as activity_month, YEAR(business_activity.created_date) as activity_year,
business_directory.business_name, activity_category.activity_description,
COUNT( CASE business_activity.activity_category WHEN 'V' THEN business_activity.business_activity_id ELSE 0 END ) AS 'Activity V',
COUNT( CASE business_activity.activity_category WHEN 'W' THEN business_activity.business_activity_id ELSE 0 END ) AS 'Activity W',
users.last_name_en AS last_name, users.email_address
FROM business_activity
JOIN business_directory on business_directory.business_id = business_activity.business_id
JOIN activity_category ON activity_category.activity_code = business_activity.activity_category
JOIN users ON users.user_id = business_directory.owner_id
WHERE business_directory.business_status = "A"
GROUP BY business_activity.business_id, business_activity.activity_category
ORDER BY business_activity.business_id;

Options: ReplyQuote


Subject
Written By
Posted
Re: Rows to Columns without duplicate rows
July 02, 2021 12:09PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.