SINTAX ERROR!!

Поиск
Список
Период
Сортировка
Искать

SINTAX ERROR!!

От:
"Gonzalo A. Aranda Corral" <garanda@bitakora.com>
Дата:


	Someone of you can see where the sentence is wrong???

SELECT Count(*) FROM (SELECT DISTINCT cdusuario FROM visitas) AS Cuenta;

...
parse error near select!!!


:(

Thanks for your help!!

gum.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/02

Re: SINTAX ERROR!!

От:
"Nick Fankhauser" <nickf@ontko.com>
Дата:
This question should be posted on the pgsql-sql list, but I'll give it a
shot.

The problem is that you are not specifying a table after the FROM. If you
are just after a distinct count of cdusuario FROM visitas, this should work:

select count(distinct cdusuario) as Cuenta from visitas;

-Nick
--------------------------------------------------------------------------
Nick Fankhauser  nickf@ontko.com  Phone 1.765.935.4283  Fax 1.765.962.9788
Ray Ontko & Co.     Software Consulting Services     http://www.ontko.com/

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Gonzalo A. Aranda
> Corral
> Sent: Wednesday, April 24, 2002 6:46 AM
> To: pgsql-jdbc@postgresql.org
> Subject: [JDBC] SINTAX ERROR!!
>
>
>
>
> 	Someone of you can see where the sentence is wrong???
>
> SELECT Count(*) FROM (SELECT DISTINCT cdusuario FROM visitas) AS Cuenta;
>
> ...
> parse error near select!!!
>
>
> :(
>
> Thanks for your help!!
>
> gum.
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/02
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

Re: SINTAX ERROR!!

От:
João Paulo Ribeiro <jp@mobicomp.com>
Дата:
Hi!

I think what you want to do is

SELECT Count( Distinct( cdusuario ) ) AS Cuenta FROM visitas;

:)

Regards.
João Paulo Ribeiro

Gonzalo A. Aranda Corral wrote:

>
>	Someone of you can see where the sentence is wrong???
>
>SELECT Count(*) FROM (SELECT DISTINCT cdusuario FROM visitas) AS Cuenta;
>
>...
>parse error near select!!!
>
>
>:(
>
>Thanks for your help!!
>
>gum.
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/02
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/users-lounge/docs/faq.html
>
>


-- 
----------------------------------------------------------------------------
MobiComp - Mobile Computing & Wireless Solutions
phone: +351 253 305 250     fax: +351 253 305 251
web: http://www.mobicomp.com
----------------------------------------------------------------------------



Re: SINTAX ERROR!!

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Gonzalo A. Aranda Corral"  writes:
> 	Someone of you can see where the sentence is wrong???

> SELECT Count(*) FROM (SELECT DISTINCT cdusuario FROM visitas) AS Cuenta;

It's not wrong (though as others have pointed out, there are other
ways to do it).  How old is your Postgres?  This should work in 7.1
or later.

			regards, tom lane
FAQ