Re: what the problem with this query

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: venu gopal <gopalonline2(at)yahoo(dot)co(dot)uk>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: what the problem with this query
Date: 2006-04-14 11:36:05
Message-ID: FBCAEF05-136A-4E49-A545-6E6877511517@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general


On Apr 14, 2006, at 20:09 , venu gopal wrote:

> Query:SELECT o.orgunitname AS ouname, e.entrynumber AS value_field,
> centroid(c.the_geom) AS the_geom, c.ogc_fid AS ogc_fid FROM (ctrphc
> AS c INNER JOIN orgunit o ON c.dhs_ouname = o.orgunitname) INNER
> JOIN (SELECT orgunitid, entrynumber FROM routinedataou4 WHERE
> dataelementid=1195 AND dataperiodid = 86) AS e ON o.orgunitid =
> e.orgunitid) AS new_table USING UNIQUE ogc_fid USING SRID=-1
>
> Error::ERROR: syntax error at or near ")" at character 333

[please don't post HTML]

I'm not familiar with the syntax you're using, but one problem is
that your parentheses are not balanced -- there's an extra closing
parenthesis. That's probably what the error is complaining about. You
might want to try to use whitespace to see the structure of your
query better, e.g.,

SELECT o.orgunitname AS ouname
, e.entrynumber AS value_field
, centroid(c.the_geom) AS the_geom
, c.ogc_fid AS ogc_fid
FROM (
ctrphc AS c
INNER JOIN orgunit o ON c.dhs_ouname = o.orgunitname)
INNER JOIN (
SELECT orgunitid
, entrynumber
FROM routinedataou4
WHERE dataelementid=1195
AND dataperiodid = 86
) AS e ON o.orgunitid = e.orgunitid) AS new_table USING UNIQUE
ogc_fid USING SRID=-1

Hope this helps a bit.

Michael Glaesemann
grzm myrealbox com

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Pierre LEBRECH 2006-04-14 12:56:19 Slony1 or DRBD for replication ?
Previous Message Guido Barosio 2006-04-14 11:31:36 Re: what the problem with this query

Browse pgsql-general by date

  From Date Subject
Next Message Kari Pahula 2006-04-14 11:51:18 Curious UDP packets
Previous Message Guido Barosio 2006-04-14 11:31:36 Re: what the problem with this query