Can this be done with SQLAhclemy / Python?

jake wong

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?)

capture

If it is not possible to do this in SQL, What do you suggest I can do that would provide similar results?

David Gomes

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Can Conditional Variable Assignment be Done in Azure Pipelines?

From Dev

Can routing urls in Spring framework be done easier?

From Dev

Can't tell when Jasmine is done running

From Dev

Can C# execution of Python script be done faster by re-using process?

From Dev

Notify a python script that a process is done

From Dev

Can this be done with Scala macros?

From Dev

Can be done more pythonic?

From Dev

How can this effect be done efficiently?

From Dev

Potentially complicated query for hasMany relationship; can this be done?

From Dev

Can this be done with formatting strings alone?

From Dev

python algorithm to be done in a pythonic fashion?

From Dev

Can I run ffmpeg from my Python code and return a signal when it's done compressing?

From Dev

Call subprocess "ls -l folder | wc -l" in python can't be done

From Dev

Executing python script from a PHP site -- do I need Django? Can it be done on a raspberry pi?

From Dev

Can this be done with regex?

From Dev

Python: Can this be done in a single list comprehension statement

From Dev

Can generating permutations be done in parallel?

From Dev

Can this be done faster with numpy?

From Dev

Can this be done with STM?

From Dev

Can OLAP CUBE be done in HBase?

From Dev

Can Hotel management done in sharepoint?

From Dev

jQuery - Can threads/asynchronous be done?

From Dev

Can this be done in a one-liner?

From Dev

Can C# execution of Python script be done faster by re-using process?

From Dev

python algorithm to be done in a pythonic fashion?

From Dev

How can use .done jquery

From Dev

Call subprocess "ls -l folder | wc -l" in python can't be done

From Dev

Can this be done with regex?

From Dev

Can the same query be done with Pivot?

Related Related

  1. 1

    Can Conditional Variable Assignment be Done in Azure Pipelines?

  2. 2

    Can routing urls in Spring framework be done easier?

  3. 3

    Can't tell when Jasmine is done running

  4. 4

    Can C# execution of Python script be done faster by re-using process?

  5. 5

    Notify a python script that a process is done

  6. 6

    Can this be done with Scala macros?

  7. 7

    Can be done more pythonic?

  8. 8

    How can this effect be done efficiently?

  9. 9

    Potentially complicated query for hasMany relationship; can this be done?

  10. 10

    Can this be done with formatting strings alone?

  11. 11

    python algorithm to be done in a pythonic fashion?

  12. 12

    Can I run ffmpeg from my Python code and return a signal when it's done compressing?

  13. 13

    Call subprocess "ls -l folder | wc -l" in python can't be done

  14. 14

    Executing python script from a PHP site -- do I need Django? Can it be done on a raspberry pi?

  15. 15

    Can this be done with regex?

  16. 16

    Python: Can this be done in a single list comprehension statement

  17. 17

    Can generating permutations be done in parallel?

  18. 18

    Can this be done faster with numpy?

  19. 19

    Can this be done with STM?

  20. 20

    Can OLAP CUBE be done in HBase?

  21. 21

    Can Hotel management done in sharepoint?

  22. 22

    jQuery - Can threads/asynchronous be done?

  23. 23

    Can this be done in a one-liner?

  24. 24

    Can C# execution of Python script be done faster by re-using process?

  25. 25

    python algorithm to be done in a pythonic fashion?

  26. 26

    How can use .done jquery

  27. 27

    Call subprocess "ls -l folder | wc -l" in python can't be done

  28. 28

    Can this be done with regex?

  29. 29

    Can the same query be done with Pivot?

HotTag

Archive