4
I have the following tables:
┌──────────────┐ ┌──────────────┐ ┌─────────────────────────────┐
│ TABLE pessoa | | TABLE lente | | TABLE pessoa_lente |
├──────────────┤ ├──────────────┤ ├─────────────────────────────┤
│ _id, NAME │ │ _id, COLOR │ │ _id, idpessoa, idlente, qty │
├──────────────┤ ├──────────────┤ ├─────────────────────────────┤
│ 1, "mary" │ │ 1, "BLACK" │ │ 1, 1, 1, 50 │
├──────────────┤ ├──────────────┤ ├─────────────────────────────┤
│ 2, "juan" │ │ 2, "BLUE" │ │ 2, 1, 3, 30 │
├──────────────┤ ├──────────────┤ ├─────────────────────────────┤
│ 3, "jose" │ │ 3, "GRAY" │ │ 3, 1, 4, 25 │
├──────────────┤ ├──────────────┤ ├─────────────────────────────┤
│ ... │ │ 4, "YELLOW" │ │ ... │
└──────────────┘ ├──────────────┤ └─────────────────────────────┘
│ 4, "YELLOW" │
└──────────────┘
And I need to get the following:
[crosstab]
NAME | BLACK | GRAY | YELLOW
"mary" | 50 | 30 | 25
...
Important Note: It’s not about join
. I would like a crosstab
, resource known in other banks such as Postgresql.
To be quite honest, as I work with robust database managers like Postgresql, with Sqlite I feel like a confectioner with only sugar as a raw material to produce the full range of possible flavors. The Sqlite NO there are a lot of things that make me feel safe using databases, rather than creating flat text like data set . Recently, for example, I discovered the case of the Boolean type (not native?!) and every day I have more surprises. I don’t think that things essential to a bank should be discarded in preference to lightness.
– AnselmoMS