Shavonne Marietta Wijesinghe wrote:
Hello
I have 2 records with the same value. Even when i do a select with
DISTINCT, it returns me both the records instead of one.
SELECT DISTINCT ON (TE_COGNOME) TE_COGNOME, TE_NOME, N_GEN_TEST,
TE_SESSO, TE_ATTNASC, TE_LUONASC, TE_INDI, TE_DTNASC, TE_PROVSTA
Hello
I have 2 records with the same value. Even when i do a select with DISTINCT, it
returns me both the records instead of one.
SELECT DISTINCT ON (TE_COGNOME) TE_COGNOME, TE_NOME, N_GEN_TEST, TE_SESSO,
TE_ATTNASC, TE_LUONASC, TE_INDI, TE_DTNASC, TE_PROVSTATO, TE_PROV,
TE_PATERNITA, TE_RICH
Aymeric Levaux <[EMAIL PROTECTED]> writes:
> SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag);
> You get the following error message :
> for SELECT DISTINCT, ORDER BY expressions must appear in select list.
> It is weird as the order by column appears in the select.
No it doesn't. The ORDER BY
On pgsql 8.2, if you do the following query, everything is fine:
SELECT DISTINCT tag FROM logs ORDER BY tag;
But if you'd like to do a case insensitive order by like this:
SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag);
or
SELECT DISTINCT tag FROM logs ORDER BY LOWER(tag);
You get the fol
* Alvaro Herrera:
> Miroslav ?ulc wrote:
>> The GROUP BY is really fast :-)
>
> Doh! How does it do it?
It uses a hash table and can therefore discard duplicate rows more
quickly (essentially linear time in the number of rows if the number
of different rows is bounded).
Greg Stark napsal(a):
Actually you could try the equivalent query:
SELECT Key FROM MRTPContactValue GROUP BY Key
This may or may not be faster because it can use a hash aggregate plan. I
would expect it to be faster here because there are few distinct keys and the
planner predicts that.
Alvaro Herrera <[EMAIL PROTECTED]> writes:
> Miroslav ?ulc wrote:
> > Well, "key" is not primary key from another table. It is just a column
> > in pair "key" => "value".
> > The structure of the table is this:
> >
> > Id (primary key)
> > MRTPContactId (id of contact from table MRTPContact)
> >
Miroslav ?ulc wrote:
> The GROUP BY is really fast :-)
Doh! How does it do it?
--
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
---(end of broadcast)---
TIP 1: if posting
The GROUP BY is really fast :-)
Thank you.
Miroslav Šulc
Tom Lane napsal(a):
> Try
> SELECT Key FROM MRTPContactValue GROUP BY Key
>
> The "select distinct" code is a bit old and crufty, GROUP BY is usually
> smarter.
>
> regards, tom lane
>
begin:vcard
fn;quoted-
=?ISO-8859-2?Q?Miroslav_=A9ulc?= <[EMAIL PROTECTED]> writes:
> I have a table with cca 400,000 rows. The table contains column "key" of
> varchar(20) type containing 10 distinct values. I want to get out what
> distinct values are present in the column. I use this simple query,
> which is very slow
It might be a good solution :-)
Thank you for your help.
Miroslav Šulc
Alvaro Herrera napsal(a):
> Miroslav ?ulc wrote:
>
>> Well, "key" is not primary key from another table. It is just a column
>> in pair "key" => "value".
>> The structure of the table is this:
>>
>> Id (primary key)
>> MR
Miroslav ?ulc wrote:
> Well, "key" is not primary key from another table. It is just a column
> in pair "key" => "value".
> The structure of the table is this:
>
> Id (primary key)
> MRTPContactId (id of contact from table MRTPContact)
> Key (key from pair key => value)
> Value (value from pair ke
Well, "key" is not primary key from another table. It is just a column
in pair "key" => "value".
The structure of the table is this:
Id (primary key)
MRTPContactId (id of contact from table MRTPContact)
Key (key from pair key => value)
Value (value from pair key => value)
So I want the get th
Miroslav ?ulc wrote:
> Hello,
>
> I have a table with cca 400,000 rows. The table contains column "key" of
> varchar(20) type containing 10 distinct values. I want to get out what
> distinct values are present in the column. I use this simple query,
> which is very slow:
>
> SELECT DISTINCT Key F
Hello,
I have a table with cca 400,000 rows. The table contains column "key"
of varchar(20) type containing 10 distinct values. I want to get out
what distinct values are present in the column. I use this simple
query, which is very slow:
SELECT DISTINCT Key FROM MRTPContactValue
Here is the
he help,
Stijn Vanroye
-Original Message-
From: Viorel Dragomir [mailto:[EMAIL PROTECTED]
Sent: woensdag 28 april 2004 11:54
To: Stijn Vanroye; [EMAIL PROTECTED]
Subject: Re: [SQL] select distinct and order by
I don't know if this will work, but why not try it ? :)
select distinc
know
:)
- Original Message -
From:
Stijn
Vanroye
To: [EMAIL PROTECTED]
Sent: Wednesday, April 28, 2004
12:27
Subject: [SQL] select distinct and order
by
Hello everybody,I have a short question:I'm
trying to run the following query:select distinct on (staff_id) staff_id,
Hello everybody,
I have a short question:
I'm trying to run the following query:
select distinct on (staff_id) staff_id, fullname, loginname from staff
where staff_id in
(select staff_id from staffmembership where staffgroup_id=#SomeIdValue#)
order by fullname
I get the follwing error:
select
Carlos <[EMAIL PROTECTED]> writes:
> Select distinct field1, field2 from table1 order by field3;
> The value return by PQresultErrorMessage is:
> For SELECT DISTINCT, ORDER BY expressions must appear in target list
> Whatever this query works fine in postgresql 6.5.3.
> Is correct this query a
On Wed, 11 Jul 2001, Carlos wrote:
> Select distinct field1, field2 from table1 order by field3;
>
> The value return by PQresultErrorMessage is:
>
> For SELECT DISTINCT, ORDER BY expressions must appear in target list
That's because this query is ambiguous.
What if table1 looks like this:
fie
Hi all:
We have developed an aplication in C with postgresql, using libpq. Our
version of development is Postgresql 6.5.3 and it works fine.
Now we are migrating the application to various flavours of Linux
(S.u.s.e 7.1, tha uses postgresql 7.0.3; Debian Potato, that uses
postgresql 7.0.2) and
From: "SCAHILL KEVIN" <[EMAIL PROTECTED]>
> I would like to pull each distinct value of LecturerName with any one
> corresponding ProjectCode value, it does not matter what the ProjectCode
> value is, but all attemps at this have failed so far.
>
> I have tried this but it does not work:
>
> Set
SCAHILL KEVIN <[EMAIL PROTECTED]> writes:
> I have tried this but it does not work:
> Set rsLecturers = Server.CreateObject("ADODB.Recordset")
> sqlLect = "Select LecturerName, MIN(ProjectCode) from tblSuggestions WHERE
> LecturerName IN ( SELECT DISTINCT LecturerName FROM tblSuggestions)"
> rsL
Hi there,
I'm having a lot of trouble with one sql statement and I wonder can you
help.
I My problem is the following...there are two field name in the the table
named LecturerName and Projectcode. Each ProjectCode vulue is unique within
the table but there can be many entries in the table with t
24 matches
Mail list logo