Re: Distinct Values
От | Stephan Szabo |
---|---|
Тема | Re: Distinct Values |
Дата | |
Msg-id | Pine.BSF.4.21.0106051411290.10996-100000@megazone23.bigpanda.com обсуждение исходный текст |
Ответ на | Distinct Values ("Nicolas" <bnk@medialife.net>) |
Список | pgsql-sql |
On Wed, 30 May 2001, Nicolas wrote: > Hi, > > I'm trying to retreive DISTINCT Values from a two colomn table called > "Books". The colomns are named "Author" and "URL". > DISTINCT values should be retieved from the "Author" Colomn , and then I > should be able to retrieve the corresponding URL. > How do I build the SQL Query ? > I tried to use: "SELECT DISTINCT Author FROM Books" But this does not allow > me to fetch the URL value on the other colomn. If there is only one distinct url for each author then: select distinct author, url from books; If not, *which* url do you want to get? If it doesn't matter, you can use a non-standard structure: select distinct on (author) author, url; If you wanted (for example) the url that could be considered the minimum, you could do something like: select author, min(url) from books group by author;
В списке pgsql-sql по дате отправления: