Re: Query

Поиск
Список
Период
Сортировка
От Thurstan R. McDougle
Тема Re: Query
Дата
Msg-id 3BA1CF2C.5CA6BD65@my-deja.com
обсуждение исходный текст
Ответ на Re: Query  ("Joe Conway" <joseph.conway@home.com>)
Список pgsql-general
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).

В списке pgsql-general по дате отправления:

Предыдущее
От: Ryan Mahoney
Дата:
Сообщение: Re: business perspective
Следующее
От: Giorgio Volpe
Дата:
Сообщение: Re: where cannot use alias name of column?