I'm trying to create a database in SQL, with python. Was wondering if it would be possible to group things together like the below image? (I know we can do this in Excel. But I was wondering if it would be possible to do it in SQL?)
If it is not possible to do this in SQL, What do you suggest I can do that would provide similar results?
Yes, it is possible to achieve that with SQL. All you have to do is create a table like this:
CREATE TABLE data (
names TEXT,
counter INT,
ratio1_2012 INT,
ratio2_2012 INT,
ratio3_2012 INT,
ratio4_2012 INT,
ratio1_2013 INT,
...
);
Of course, this is not a very "pretty" solution and so it might be better to have one table per year:
CREATE TABLE data2012 (
names TEXT,
counter INT,
ratio1 INT,
...
)
...
In the end, which approach you want to take depends on how much data you have and how much of a concern is space vs query execution speed to you. If you have two tables, you have a lot of duplicated data (all names for instance).
Visually, either method works fine you just have to adapt the frontend code in the necessary way.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments