I have a table t1 like this:
Names Drug Tom A Tom A Tom B Lily B Lily B and a table t2 like this:
Names Drug COUNT(Drug) Tom A Tom B Tom C Lily A Lily B I want to insert into the COUNT(drug) column of t2 the data from t1 after grouping by drug and name. The desired output of t2 looks like this:
Names Drug COUNT(Drug) Tom A 2 Tom B 1 Tom C 0 Lily A 0 Lily B 2 I am thinking about creating another table t3 with the GROUP BY drug, name data from t1 and then UPDATE t2 based on t3 but it is quite time-consuming.