mercredi 23 septembre 2015

Creating views with different columns than table

I have a SQL table, which has entries out of which one of the columns is date.

table1

       ------------------------------------------
       | visit_to | visit_by | visit_on | value |
       ------------------------------------------
            x           a       2/2/15     1
            x           b      16/02/15    2
            y           c      18/02/15    3

I want to present the data to the user like this:

table2

       -----------------------------------
       | value | Fortnite 1 | fortnite 2 |
       -----------------------------------
           x         a            b
           y                      c

now a fortnite is from 1st day of the month to 15th day of the same month.
table1 has the list of visits made by a, b and c and the dates of theirs visits, the person x gets 2 visits one in each fortnite. And y gets only 1 visit in second fortnite.

The table2 should compare these dates and present data in shown format. How can I do this? I'm using Sqlite.

Aucun commentaire:

Enregistrer un commentaire