I'm utilizing MySQL 5.7 and need to construct an SQL query to establish a view. The purpose of this view creation is to facilitate our clients who are using Metabase for querying our database and generating graphs. The task at hand involves creating a separate column for each existing record in table_a. To illustrate, assume we have the following rows in table_a: 'one', 'two', 'three', I would require columns to be created accordingly.
table_b.value, one_amount, one_date, two_amount, two_date, three_amount, three_date
Value1 45 2023-05-01 null null 50 2023-08-15
Value2 null null null null 80 2023-04-10
CREATE TABLE `table_a` (
`id` bigint(20) UNSIGNED NOT NULL,
`value` varchar(255)
);
CREATE TABLE `table_b` (
`id` bigint(20) UNSIGNED NOT NULL,
`value` varchar(255) DEFAULT NULL
);
CREATE TABLE `table_c` (
`id` bigint(20) UNSIGNED NOT NULL,
`table_a_id` bigint(20) UNSIGNED DEFAULT NULL,
`table_b_id` bigint(20) UNSIGNED DEFAULT NULL,
`amount` int DEFAULT 0,
`date` date DEFAULT NULL
);
It is possible to do this with MySQL ? Or there is another way to do that on Metabase ?