Thread: Query

Query

From
"Tamara D. Blum"
Date:
Hi !
 
    I'm trying to execute the following query:
        "SELECT TOP 10 * FROM table1"
 
    It gives me the error message
    parser: parse error at or near "2"
 
    Can i use SELECT TOP ?
    Is there any other way to execute the same query not using SELECT TOP ?
 
    Thanks
	            Tamara D. Blum
	        Analista de Sistemas
	        Tel.: 4831-9061 al 66 int. 110  
	Sistema Argentino de Informática Jurídica
	Ministerio de Justicia y Derechos Humanos

Re: Query

From
"Mitch Vincent"
Date:
>     I'm trying to execute the following query:
>         "SELECT TOP 10 * FROM table1"

SELECT * FROM table1 LIMIT 10

 -- might give you what you're looking for.. I've not seen TOP, though I
could guess where it comes from (Oracle?) -- top seems to imply order so you
might want to ORDER BY something in the query before you LIMIT ...

-Mitch



Re: Query

From
"Joe Conway"
Date:
> Hi !
>
>     I'm trying to execute the following query:
>         "SELECT TOP 10 * FROM table1"
>
>     It gives me the error message
>     parser: parse error at or near "2"
>
>     Can i use SELECT TOP ?
>     Is there any other way to execute the same query not using SELECT TOP
?
>

See the LIMIT clause:
http://www.postgresql.org/idocs/index.php?sql-select.html

Hope this helps,

-- Joe


Re: Query

From
"Thurstan R. McDougle"
Date:
TOP is the MS Access equivelant to LIMIT

Text (cut down) from Access 97 help:-
Syntax
    SELECT [ALL | DISTINCT | DISTINCTROW | [TOP n [PERCENT]]]
    FROM table

TOP n [PERCENT]    Returns a certain number of records that fall at the top
of a range specified by an ORDER BY clause.  If you don't include the
ORDER BY clause, the query will return an arbitrary set of records.  The
TOP predicate doesn't choose between equal values.  You can also use the
PERCENT reserved word to return a certain percentage of records that
fall at the top of a range specified by an ORDER BY clause.


What this does not mention, although the syntax shows it, is that the
'predicates' (ALL | DISTINCT | DISTINCTROW | [TOP n [PERCENT]) must be
between the SELECT and the return list, and if more than one is used
must be in the specified order. (DISTINCT/DISTINCTROW before TOP)

However postgresql seems to requires LIMIT to be at the end of the
SELECT (only OFFSET after it). Also there is no PERCENT clause
available.

Joe Conway wrote:
>
> > Hi !
> >
> >     I'm trying to execute the following query:
> >         "SELECT TOP 10 * FROM table1"
> >
> >     It gives me the error message
> >     parser: parse error at or near "2"
> >
> >     Can i use SELECT TOP ?
> >     Is there any other way to execute the same query not using SELECT TOP
> ?
> >
>
> See the LIMIT clause:
> http://www.postgresql.org/idocs/index.php?sql-select.html
>
> Hope this helps,
>
> -- Joe
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
This is the identity that I use for NewsGroups. Email to
this will just sit there. If you wish to email me replace
the domain with knightpiesold . co . uk (no spaces).