Write POSTGRESS select statement, count and unique

Completato Pubblicato Dec 15, 2014 Pagato alla consegna
Completato Pagato alla consegna

I have a table that looks this:

ID | Record | Name | Category

1 12345 Juan Inf General

2 67897 Bill Sports

3 18787 Sandip Inf General

4 38799 Sandip Inf General

5 45791 Sandip Inf General

6 70787 Francis Inf General

7 90447 Allan Sports

8 11100 Aswan Gaming

I need a postgres (9.3) select statement that would return the "count" data like this:

Category | count

----------+-------

Inf General | 2

Sports | 2

Gaming | 1

Note above that the counter should only increment when the value for Name is unique...

One statement that gives the counts but gives the wrong data is this:

statement SELECT category, COUNT(*) FROM "table" GROUP BY category

this gives data like this:

Category | count

----------+-------

Inf General | 5

Sports | 2

Gaming | 1

PostgreSQL

Rif. progetto: #6869537

Info sul progetto

5 proposte Progetto a distanza Attivo Dec 15, 2014

Assegnato a:

VictorDuran

Hi Sir, your problem is in the grouping function and probably you'll need a sub-query, I can solve this for you very quickly. Please, consider my bid and contact me if you have any question... PD: it sould be 3 of 'inf Altro

$15 USD in 0 giorni
(1 Recensione)
0.4

5 freelance hanno fatto un'offerta media di $18 per questo lavoro

joseluiselp

Hi im doing nothing right now, i can help you with this. Let me know if you are interested. Regards jose luis mendoza, programer and designer.

$20 USD in 0 giorni
(4 valutazioni)
3.3
AndrwProjects

Hi ePrensaSL. I think that select is possible.

$20 USD in 3 giorni
(2 valutazioni)
2.8
acuenca

Hello, I'm a developer from Venezuela with expertise in SQL. This is a very simple job and I can get it done for you. Regards

$20 USD in 0 giorni
(0 valutazioni)
0.0
gis7891

Good morning Sir, I have already solved a similar problem in the past so I know to fix it. I have great familiarity with PostgreSQL, I use it. Have a nice evening. Andrea Gagna

$17 USD in 1 giorno
(0 valutazioni)
0.0