Skip to content

Tag: mysql

How to compare column combinations from two tables?

I have two tables from different years, 2015 and 2016. Both tables have three columns as exampled below in table_2015: I want to see how many people had the same plan type between the years and how many people switched plan types. How do I go about doing this? Answer If customers are in each table only once a…

Getting wrong sum when using group by with inner join

With reference to this question (How to get the sum in a joined table when using group by – getting wrong results) I have two tables orders and order_items. I need to group the results by days. But I also need to get the sum of energy_used for each day from another table. When I try that using a join,