Re: [SQL] sort by on two columns

2004-01-02 Thread Michael Glaesemann
Hi Andy, On Jan 2, 2004, at 7:15 PM, Andy Lewis wrote: Is it possible to sort by two columns? Using the query below? SELECT table1.name, table2.name, FROM table1, table2 WHERE table1.id = table2.id ORDER BY I want to be able to sort the names select from two different tables and two different

Re: [SQL] sort by on two columns

2004-01-02 Thread Chris Travers
Title: Message SELECT * FROM customers ORDER BY last_name, first_name Works for me. - Original Message - From: Andy Lewis To: [EMAIL PROTECTED] Sent: Saturday, January 03, 2004 8:15 AM Subject: [SQL] sort by on two columns Hi All, Is it possible to

Re: [SQL] sort by on two columns

2004-01-02 Thread Adam Ruth
Sounds like you may want to concatenate the columns: ... order by table1.name || table2.name The sorting would then be performed on both of the them as though they were one column. Adam Ruth On Jan 2, 2004, at 8:04 PM, Michael Glaesemann wrote: On Jan 2, 2004, at 8:55 PM, Andy Lewis wrote: Ye

Re: [SQL] sort by on two columns

2004-01-02 Thread Michael Glaesemann
On Jan 2, 2004, at 8:55 PM, Andy Lewis wrote: Yes, I understand this but, I would like to have the results of both "table1.name, table2.name" sorted as one column. Is this possible? So you want one column of name, including names from both table1 and table2? In that case, you need to use UNION, I

Re: [SQL] sort by on two columns

2004-01-02 Thread Andy Lewis
Hi Michael, Yes, I understand this but, I would like to have the results of both "table1.name, table2.name" sorted as one column. Is this possible? Thanks, Andy -Original Message- From: Michael Glaesemann [mailto:[EMAIL PROTECTED] Sent: Friday, January 02, 2004 8:40 PM To: Andy Lewis

Re: [SQL] Ambiguous error message

2004-01-02 Thread Bertrand Petit
On Fri, Jan 02, 2004 at 05:49:46PM +0100, Samuel Tardieu wrote: > > select texten, total > from (select protocolid, count(*) as total) from ips where catid=1 ^ +--- There > group by protocolid order by pr

[SQL] sort by on two columns

2004-01-02 Thread Andy Lewis
Title: Message Hi All, Is it possible to sort by two columns? Using the query below?   SELECT table1.name, table2.name,  FROM table1, table2 WHERE table1.id = table2.id ORDER BY   I want to be able to sort the names select from two different tables and two different colums(same data type)

Re: [SQL] Ambiguous error message

2004-01-02 Thread Michael Fuhr
On Fri, Jan 02, 2004 at 05:49:46PM +0100, Samuel Tardieu wrote: > In PostgreSQL 7.4, the following select: > > select texten, total > from (select protocolid, count(*) as total) from ips where catid=1 > group by protocolid order by protocolid) as c > inner join protocols using (protocolid)

Re: [SQL] Ambiguous error message

2004-01-02 Thread Samuel Tardieu
On 3/01, Samuel Tardieu wrote: | On 2/01, Michael Glaesemann wrote: | | | I'm not quite sure what you want the query to return, but you've got a | | problem with your parentheses. | | I can't believe this :) I got hit by the "inner query needs to be aliased" | message and added it to the wron

Re: [SQL] Ambiguous error message

2004-01-02 Thread Samuel Tardieu
On 2/01, Michael Glaesemann wrote: | I'm not quite sure what you want the query to return, but you've got a | problem with your parentheses. I can't believe this :) I got hit by the "inner query needs to be aliased" message and added it to the wrong place and them munged the query a lot. The c

Re: [SQL] Ambiguous error message

2004-01-02 Thread Tom Lane
Samuel Tardieu <[EMAIL PROTECTED]> writes: > In PostgreSQL 7.4, the following select: > select texten, total > from (select protocolid, count(*) as total) from ips where catid=1 > group by protocolid order by protocolid) as c > inner join protocols using (protocolid); > gives the error mes

Re: [SQL] Ambiguous error message

2004-01-02 Thread Michael Glaesemann
Hi Sam, I'm not quite sure what you want the query to return, but you've got a problem with your parentheses. You've got two FROM clauses and an INNER JOIN, which together aren't arranged properly. I've rearranged your query a little, but I haven't changed anything. Perhaps this'll make it a l

[SQL] Ambiguous error message

2004-01-02 Thread Samuel Tardieu
In PostgreSQL 7.4, the following select: select texten, total from (select protocolid, count(*) as total) from ips where catid=1 group by protocolid order by protocolid) as c inner join protocols using (protocolid); gives the error message: ERROR: subquery in FROM must have an alias HIN