lundi 20 avril 2015

How can I replace a column value with a name in an SQL query?

I am running this query:

SELECT type, COUNT(type) FROM "table" where id = 8 GROUP BY type;

With this result:

6 3814 8 341 5 328

I'd like to have something like this, where I can specify names:

Arbitrary Name 3814 Other name 341 Test Name 328

Instead of the type column listing 6, how can I get it to have a custom name like Test Column 6, or Fun Column 5? I'm using postgres.

Aucun commentaire:

Enregistrer un commentaire