Re: [GENERAL] ORDER BY for jsonb

2015-04-19 Thread Pai-Hung Chen
​Thanks for the insight. Pai-Hung

Re: [GENERAL] ORDER BY for jsonb

2015-04-18 Thread Jim Nasby
On 4/18/15 1:30 AM, Pai-Hung Chen wrote: Thanks for the help. So in this case, the performance of ORDER BY will not be affected at all by whether an index is created on the jsonb "setting" field? No. The optimizer is going to first try and satisfy the WHERE clause with that relevant index. Bec

Re: [GENERAL] ORDER BY for jsonb

2015-04-17 Thread Pai-Hung Chen
"pgsql-general@postgresql.org" Subject: Re: [GENERAL] ORDER BY for jsonb On 4/17/15 9:53 PM, Pai-Hung Chen wrote: > Hi, > > I am new to PostgreSQL and have a question about the new jsonb type in > 9.4. Suppose I have a table called "user" that has two columns: (1) &g

Re: [GENERAL] ORDER BY for jsonb

2015-04-17 Thread Jim Nasby
On 4/17/15 9:53 PM, Pai-Hung Chen wrote: Hi, I am new to PostgreSQL and have a question about the new jsonb type in 9.4. Suppose I have a table called "user" that has two columns: (1) "user_id" of type text, also the primary key, (2) "setting" of type jsonb. With the following query pattern: SE

[GENERAL] ORDER BY for jsonb

2015-04-17 Thread Pai-Hung Chen
Hi, I am new to PostgreSQL and have a question about the new jsonb type in 9.4. Suppose I have a table called "user" that has two columns: (1) "user_id" of type text, also the primary key, (2) "setting" of type jsonb. With the following query pattern: SELECT * FROM user WHERE user_id IN [...] ORD

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread David Johnston
> > > On Wed, Jan 21, 2015 at 4:09 PM, Bryn Jeffries < > bryn.jeffr...@sydney.edu.au> wrote: > >> >> Maybe what we need in ODBC libs and the like is a "protected >> statement" that follows the same construction as a prepared statement but >> additionally checks catalogs to validate identifiers. >>

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Adrian Klaver
On 01/21/2015 03:09 PM, Bryn Jeffries wrote: Paul Jungwirth wrote I'm not sure how to make a prepared statement that lets you name a column when you execute it. Maybe someone else can chime in if that's possible. David J. responded You cannot. By definition parameters, in this context, are v

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread David Johnston
On Wed, Jan 21, 2015 at 4:09 PM, Bryn Jeffries wrote: > Paul Jungwirth wrote > > I'm not sure how to make a prepared statement that lets you name a > > column when you execute it. Maybe someone else can chime in if that's > > possible. > > David J. responded > > You cannot. By definition paramet

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Bryn Jeffries
Paul Jungwirth wrote > I'm not sure how to make a prepared statement that lets you name a > column when you execute it. Maybe someone else can chime in if that's > possible. David J. responded > You cannot. By definition parameters, in this context, are values - not > identifiers. > [...] > In

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Bryn Jeffries
@postgresql.org" Subject: [GENERAL] ORDER BY in prepared statements Date: Thu, Jan 22, 2015 08:18 On 01/21/2015 12:51 PM, Bryn Jeffries wrote: > In a number of places on the web I've seen it claimed that ordering can > be set via prepared statements. Can you give a link t

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread David G Johnston
Paul Jungwirth wrote >> In a number of places on the web I've seen it claimed that ordering can >> be >> set via prepared statements. >> ... >> sandbox=# PREPARE testplan(text) AS >> SELECT * FROM test ORDER BY $1; >> >> But the output is not what one would expect: >> >> sandbox=# EXECUTE testplan(

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Adrian Klaver
On 01/21/2015 12:51 PM, Bryn Jeffries wrote: In a number of places on the web I've seen it claimed that ordering can be set via prepared statements. Can you give a link to one of those examples? Many thanks, Bryn -- Adrian Klaver adrian.kla...@aklaver.com -- Sent via pgsql-general mail

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Paul Jungwirth
> In a number of places on the web I've seen it claimed that ordering can be > set via prepared statements. > ... > sandbox=# PREPARE testplan(text) AS > SELECT * FROM test ORDER BY $1; > > But the output is not what one would expect: > > sandbox=# EXECUTE testplan('gender'); > ... > As opposed to:

[GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Bryn Jeffries
In a number of places on the web I've seen it claimed that ordering can be set via prepared statements. Indeed, the expected syntax is accepted on my 9.3 server without errors: sandbox=# CREATE TABLE test ( id serial PRIMARY KEY, gender char ); sandbox=# INSERT INTO test(gender) VALUES('m') VA

Re: [GENERAL] order by question

2014-08-07 Thread Kevin Grittner
Steve Clark wrote: > It is like the space character and the - in -Letter is ignored. Yes, that is how the en_US collation is defined.  I think the goal is to make it something like "phone book" ordering.  If you still have a "white pages" book around, look at how a business name with a hyphen (o

Re: [GENERAL] order by question

2014-08-07 Thread Steve Clark
On 08/07/2014 11:36 AM, Kevin Grittner wrote: Steve Clark wrote: I am confused by how postgres 8,4..13 is sorting my data. select * from test order by data; data -- - -- 1 11 11F 1F a b C F -F Feneric Generic (14 rows) The fir

Re: [GENERAL] order by question

2014-08-07 Thread Kevin Grittner
Steve Clark wrote: > I am confused by how postgres 8,4..13 is sorting my data. > select * from test order by data; > data > -- > >   - >   -- >   1 >   11 >   11F >   1F >   a >   b >   C >   F >   -F >   Feneric >   Generic > (14 rows) > > The first row is a single space, the next r

[GENERAL] order by question

2014-08-07 Thread Steve Clark
Hello, I am confused by how postgres 8,4..13 is sorting my data. \d test Table "public.test" Column | Type | Modifiers +--+--- data | text | select * from test order by data; data -- - -- 1 11 11F 1F a b C F -F Feneric Generic (14 rows) Th

Re: [GENERAL] Order By and Comparisson

2014-04-10 Thread Alberto Cabello Sánchez
On Mon, 07 Apr 2014 11:04:23 +0100 "howardn...@selestial.com" wrote: > Hi, > > just as I thought I had postgres mastered :) the ordering of strings is > causing me some confusion. > > Can someone explain how the database orders strings in the ORDER BY command. > > My example: > > My databas

Re: [GENERAL] Order By and Comparisson

2014-04-07 Thread Albe Laurenz
howardn...@selestial.com wrote: >> http://www.postgresql.org/docs/current/static/collation.html#AEN33298 >> The ordering depends on the collation. Which collations are available >> and how they order depends on your operating system. What is your OS >> and what do you get for SHOW lc_collate; Yours

Re: [GENERAL] Order By and Comparisson

2014-04-07 Thread howardn...@selestial.com
On 07/04/2014 11:58, Albe Laurenz wrote: http://www.postgresql.org/docs/current/static/collation.html#AEN33298 The ordering depends on the collation. Which collations are available and how they order depends on your operating system. What is your OS and what do you get for SHOW lc_collate; Your

Re: [GENERAL] Order By and Comparisson

2014-04-07 Thread Albe Laurenz
howardn...@selestial.com wrote: > just as I thought I had postgres mastered :) the ordering of strings is > causing me some confusion. > > Can someone explain how the database orders strings in the ORDER BY command. > > My example: > > My database is encoding is UTF-8, and default language is e

[GENERAL] Order By and Comparisson

2014-04-07 Thread howardn...@selestial.com
Hi, just as I thought I had postgres mastered :) the ordering of strings is causing me some confusion. Can someone explain how the database orders strings in the ORDER BY command. My example: My database is encoding is UTF-8, and default language is english, If I have a text column in a ta

Re: [GENERAL] Order by with column ordinal and collate - fails to parse

2013-06-20 Thread Tim Kane
Nice one. Yep, that works. Cheers.. I'll submit a bug report for this, though I'm on the fence as to wether this is actually a bug per se.. I would have reasonably expected my original syntax to have worked (as it does without any ORDER BY).. On Thu, Jun 20, 2013 at 3:44 PM, Adrian Klaver wrote:

Re: [GENERAL] Order by with column ordinal and collate - fails to parse

2013-06-20 Thread Adrian Klaver
On 06/20/2013 07:05 AM, Tim Kane wrote: Hi all, I seem to be having problems constructing a query that combines the use of distinct, order by, and collate key words. For instance: # select distinct(value) from properties order by 1 collate "C"; ERROR: collations are not supported by type int

[GENERAL] Order by with column ordinal and collate - fails to parse

2013-06-20 Thread Tim Kane
Hi all, I seem to be having problems constructing a query that combines the use of distinct, order by, and collate key words. For instance: # select distinct(value) from properties order by 1 collate "C"; ERROR: collations are not supported by type integer LINE 1: ... distinct(value) from pro

[GENERAL] ORDER BY expression required in SELECT if DISTINCT

2013-03-17 Thread Pawel Veselov
Hi. Anything I can do about this? Seems that the problem is that the query is a prepared statement, even if the parameters ($1 and $6) are the same. ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list at character 493 STATEMENT: SELECT DISTINCT t0.package_name, ts_rank(t

Re: [GENERAL] order by, within a plpgsql fx

2011-12-02 Thread Tom Lane
writes: > Please consider this plpgsql function: > = = = = = = = = = = > CREATE Or Replace FUNCTION fx_order_by ( ) > RETURNS table( last_name text, first_name ) > AS $eofx$ > DECLARE > -- > BEGIN > Return Query > select > lname, fname > from > my_table > order by > lname ASC

[GENERAL] order by, within a plpgsql fx

2011-12-02 Thread david.sahagian
Please consider this plpgsql function: = = = = = = = = = = CREATE Or Replace FUNCTION fx_order_by ( ) RETURNS table( last_name text, first_name ) AS $eofx$ DECLARE -- BEGIN Return Query select lname, fname from my_table order by lname ASC ; END; $eofx$ LANGUAGE plpgsql; = =

Re: [GENERAL] order by and view def.

2011-06-16 Thread Tom Lane
salah jubeh writes: > There is something strange with the views definitions, I have "order by" > statement amended to the views where the view is ordered by all the columns > in > the view. Is this a common behavior? > Ps: I am using postgresql 8.3 If the views use SELECT DISTINCT, PG version

[GENERAL] order by and view def.

2011-06-16 Thread salah jubeh
Hello, There is something strange with the views definitions, I have "order by" statement amended to the views where the view is ordered by all the columns in the view. Is this a common behavior? Ps: I am using postgresql 8.3 Regards

Re: [GENERAL] Order by and strings

2010-02-09 Thread Magnus Hagander
On Tue, Feb 9, 2010 at 11:21, Fredric Fredricson wrote: > Scott Marlowe wrote: > > On Tue, Feb 9, 2010 at 1:42 AM, Fredric Fredricson > wrote: > > > I use locale en_US.UTF-8 but why this should affect how leading characters > in strings are ignored is beyond me. > > > P.s. this page may shed some

Re: [GENERAL] Order by and strings

2010-02-09 Thread Fredric Fredricson
Scott Marlowe wrote: On Tue, Feb 9, 2010 at 1:42 AM, Fredric Fredricson wrote: I use locale en_US.UTF-8 but why this should affect how leading characters in strings are ignored is beyond me. P.s. this page may shed some light on the subject: http://en.wikipedia.org/wiki/Collation OK,

Re: [GENERAL] Order by and strings

2010-02-09 Thread Scott Marlowe
On Tue, Feb 9, 2010 at 1:42 AM, Fredric Fredricson wrote: > I use locale en_US.UTF-8 but why this should affect how leading characters > in strings are ignored is beyond me. P.s. this page may shed some light on the subject: http://en.wikipedia.org/wiki/Collation -- Sent via pgsql-general mail

Re: [GENERAL] Order by and strings

2010-02-09 Thread Scott Marlowe
On Tue, Feb 9, 2010 at 1:42 AM, Fredric Fredricson wrote: > Justin Graf wrote: > > On 2/8/2010 7:09 PM, Fredric Fredricson wrote: > > Hi! > New to the list with a question that I cannot find the answer to in the > manual or on the internet but I suspect is trivial. If somebody could point > me in

Re: [GENERAL] Order by and strings

2010-02-09 Thread Fredric Fredricson
Justin Graf wrote: On 2/8/2010 7:09 PM, Fredric Fredricson wrote: Hi! New to the list with a question that I cannot find the answer to in the manual or on the internet but I suspect is trivial. If somebody could point me in the correct direction I would be greatful. This is what I do (conden

Re: [GENERAL] Order by and strings

2010-02-08 Thread Justin Graf
On 2/8/2010 7:09 PM, Fredric Fredricson wrote: > Hi! > New to the list with a question that I cannot find the answer to in > the manual or on the internet but I suspect is trivial. If somebody > could point me in the correct direction I would be greatful. > > This is what I do (condensed, of cour

[GENERAL] Order by and strings

2010-02-08 Thread Fredric Fredricson
Hi! New to the list with a question that I cannot find the answer to in the manual or on the internet but I suspect is trivial. If somebody could point me in the correct direction I would be greatful. This is what I do (condensed, of course): # create table tmp ( x text ) ; CREATE TABLE # inse

Re: [GENERAL] Order By Date Question

2009-09-08 Thread David Fetter
On Tue, Sep 08, 2009 at 06:29:28AM -0700, BlackMage wrote: > > I have a question about ordering by date. I have a table with two fields and > some date > > Name(character varying) | Event_Date(timestamp with timezone) > A |2009-09-10 5:30:00 > B

Re: [GENERAL] Order By Date Question

2009-09-08 Thread Sam Mason
On Tue, Sep 08, 2009 at 06:29:28AM -0700, BlackMage wrote: > I want to order by date and then by name, so I want the result A,B,C,D. The > problem is when I do a 'SELECT * FROM table_name ORDER BY Event_Date, DESC', > it includes the actual time (HH:MM:SS) so the order comes out B,A,D,C. > > So wh

Re: [GENERAL] Order By Date Question

2009-09-08 Thread Adrian Klaver
On Tuesday 08 September 2009 6:29:28 am BlackMage wrote: > I have a question about ordering by date. I have a table with two fields > and some date > > Name(character varying) | Event_Date(timestamp with timezone) > A |2009-09-10 5:30:00 > B

Re: [GENERAL] Order By Date Question

2009-09-08 Thread A. Kretschmer
In response to BlackMage : > > I have a question about ordering by date. I have a table with two fields and > some date > > Name(character varying) | Event_Date(timestamp with timezone) > A |2009-09-10 5:30:00 > B |2009-0

Re: [GENERAL] Order By Date Question

2009-09-08 Thread Bill Moran
In response to BlackMage : > > I have a question about ordering by date. I have a table with two fields and > some date > > Name(character varying) | Event_Date(timestamp with timezone) > A |2009-09-10 5:30:00 > B |2009-

[GENERAL] Order By Date Question

2009-09-08 Thread BlackMage
I have a question about ordering by date. I have a table with two fields and some date Name(character varying) | Event_Date(timestamp with timezone) A |2009-09-10 5:30:00 B |2009-09-10- 00:00:00 C

Re: [GENERAL] Order by parameter inside pgsql function ignored

2009-06-02 Thread A. Kretschmer
In response to Anton Marchenkov : > Hi! > > I'm trying to use the order by parameter inside a function, but it is > ignored. Any ideas why? And how can I sort by external parameters inside > pgsql function? You an use dynamic SQL with EXECUTE, for instance: create or replace function my_order

Re: [GENERAL] Order by parameter inside pgsql function ignored

2009-06-02 Thread Leif B. Kristensen
On Tuesday 2. June 2009, Anton Marchenkov wrote: >CREATE OR REPLACE FUNCTION "public"."test_order_by" (sort_key varchar) >RETURNS SETOF "customers"."customers_with_mark_deleted" AS >$body$ >DECLARE > rec RECORD; >BEGIN > FOR rec IN SELECT * FROM customers.customers_with_mark_deleted c >

Re: [GENERAL] Order by parameter inside pgsql function ignored

2009-06-02 Thread Leif B. Kristensen
On Tuesday 2. June 2009, Anton Marchenkov wrote: >Hi! > >I'm trying to use the order by parameter inside a function, but it is >ignored. Any ideas why? And how can I sort by external parameters > inside pgsql function? What's the problem with SELECT * FROM foo(myvar) ORDER BY sort_key ASC ? If

[GENERAL] Order by parameter inside pgsql function ignored

2009-06-02 Thread Anton Marchenkov
Hi! I'm trying to use the order by parameter inside a function, but it is ignored. Any ideas why? And how can I sort by external parameters inside pgsql function? CREATE OR REPLACE FUNCTION "public"."test_order_by" (sort_key varchar) RETURNS SETOF "customers"."customers_with_mark_deleted" AS

Re: [GENERAL] ORDER BY: lexicographic ordering of names

2009-03-18 Thread Edoardo Panfili
Il 18-03-2009 21:32, Bryan Herger ha scritto: All, I am porting a database from MS SQL Server to Postgres. One of the tables contains a list of names, which I would like to list alphabetically. I noticed in the “O” names the following difference: MSSQL: O’Daniel O’Neill Oliveira Oliver While P

Re: [GENERAL] ORDER BY: lexicographic ordering of names

2009-03-18 Thread Tom Lane
Alvaro Herrera writes: > Bryan Herger wrote: >> I am porting a database from MS SQL Server to Postgres. One of the >> tables contains a list of names, which I would like to list >> alphabetically. I noticed in the "O" names the following difference: > Note to whoever answers: this is a frequent

Re: [GENERAL] ORDER BY: lexicographic ordering of names

2009-03-18 Thread Alvaro Herrera
Bryan Herger wrote: > I am porting a database from MS SQL Server to Postgres. One of the > tables contains a list of names, which I would like to list > alphabetically. I noticed in the "O" names the following difference: Note to whoever answers: this is a frequent question, so consider adding

[GENERAL] ORDER BY: lexicographic ordering of names

2009-03-18 Thread Bryan Herger
All, I am porting a database from MS SQL Server to Postgres. One of the tables contains a list of names, which I would like to list alphabetically. I noticed in the "O" names the following difference: MSSQL: O'Daniel O'Neill Oliveira Oliver While PGSQL sorts as if the apostrophe w

Re: [GENERAL] Order by question

2008-11-26 Thread Thomas Kellerer
Kevin Kempter wrote on 26.11.2008 20:46: Hi All; I'm selecting 3 columns. I want to order the results ascending by col1 and col2 and then descending by col3 Whats the syntax for this? ORDER BY col1 ASC, col2 ASC, col3 DESC this is documented in the manual -- Sent via pgsql-general maili

Re: [GENERAL] Order by question

2008-11-26 Thread Andreas Kretschmer
Kevin Kempter <[EMAIL PROTECTED]> schrieb: > Hi All; > > I'm selecting 3 columns. I want to order the results ascending by col1 and > col2 and then descending by col3 > > Whats the syntax for this? order by col1 asc, col2 asc, col3 desc; Andreas -- Really, I'm not out to destroy Microsoft.

Re: [GENERAL] Order by question

2008-11-26 Thread Grzegorz Jaśkiewicz
On Wed, Nov 26, 2008 at 7:46 PM, Kevin Kempter <[EMAIL PROTECTED]>wrote: > Hi All; > > I'm selecting 3 columns. I want to order the results ascending by col1 and > col2 and then descending by col3 > > Whats the syntax for this? > select * from foo order by a,b asc, c desc; ? -- GJ

[GENERAL] Order by question

2008-11-26 Thread Kevin Kempter
Hi All; I'm selecting 3 columns. I want to order the results ascending by col1 and col2 and then descending by col3 Whats the syntax for this? Thanks in advance -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.

Re: [GENERAL] Order by with spaces and other characters

2008-10-25 Thread Tomasz Myrta
mike stanton napisal 24.10.2008 21:03: Hello everyone. We have a simple problem...that we have keys that include blanks and various other commonly used characters like ",", ";" and "-". For some reason, the select we have, nothing complicated, ignores these "special" characters and happily so

[GENERAL] Order by with spaces and other characters

2008-10-24 Thread mike stanton
Hello everyone. We have a simple problem...that we have keys that include blanks and various other commonly used characters like ",", ";" and "-". For some reason, the select we have, nothing complicated, ignores these "special" characters and happily sorts by the A-z range. How do we sort by t

Re: [GENERAL] order by x using varchar_pattern_ops

2008-08-20 Thread Tom Lane
"Scott Marlowe" <[EMAIL PROTECTED]> writes: > But is there a way to force a use of varchar_pattern_ops on a column > used in an order by? ORDER BY x USING ~<~("asc" direction) ORDER BY x USING ~>~("desc" direction) (assuming those are the right names of the operators, I'm too lazy to chec

[GENERAL] order by x using varchar_pattern_ops

2008-08-20 Thread Scott Marlowe
OK, so I know about varchar_pattern_ops for things like matching with like in a non C locale. But is there a way to force a use of varchar_pattern_ops on a column used in an order by? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http

Re: [GENERAL] ORDER BY FIELD feature

2008-05-12 Thread Guillaume Lelarge
Kevin Reynolds a écrit : Does postgresql have something similar to the ORDER BY FIELD feature found in MySQL? Something like ORDER BY FIELD(ID, 10, 2, 56, 40); It is listed here: http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html I am using the Sphinx Search program, www.sphinxsearch

[GENERAL] ORDER BY FIELD feature

2008-05-12 Thread Kevin Reynolds
Does postgresql have something similar to the ORDER BY FIELD feature found in MySQL? Something like ORDER BY FIELD(ID, 10, 2, 56, 40); It is listed here: http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html I am using the Sphinx Search program, www.sphinxsearch.com, and it r

Re: [GENERAL] ORDER BY a string

2007-11-06 Thread Tom Lane
phazon <[EMAIL PROTECTED]> writes: > I've "**" before the name in order to display them at first, but the 2 > chars "**" are ignored in the order by. What's your lc_collate setting? In locales other than "C" this is not at all unexpected. regards, tom lane --

[GENERAL] ORDER BY a string

2007-11-06 Thread phazon
Hi, I've to order by q query by a column. SELECT a.id, a.nom FROM table a ORDER BY a.nom; And i've something strange. It's order like that: 5 | 8 | aaab 15 | ** aaac 6 | aaad I've "**" before the name in order to display them at first, but the 2 chars "**" are ignored in the order b

Re: [GENERAL] ORDER BY - problem with NULL values

2007-10-12 Thread Tommy Gildseth
Stefan Schwarzer wrote: Hi there, if I order a given year in DESCending ORDER, so that the highest values (of a given variable) for the countries are displayed at the top of the list, then actually the NULL values appear as first. Only below, I find the values ordered correctly. Is there an

Re: [GENERAL] ORDER BY - problem with NULL values

2007-10-12 Thread Nico Sabbi
Stefan Schwarzer ha scritto: From 8.3 beta release notes: - ORDER BY ... NULLS FIRST/LAST I think this is what you want right? Yes, indeed. Sounds great. unfortunately I am on 8.1. And wouldn't really want to migrate to 8.3 and beta for the moment order by 1 ? ---

Re: [GENERAL] ORDER BY - problem with NULL values

2007-10-11 Thread Stefan Schwarzer
From 8.3 beta release notes: - ORDER BY ... NULLS FIRST/LAST I think this is what you want right? Yes, indeed. Sounds great. unfortunately I am on 8.1. And wouldn't really want to migrate to 8.3 and beta for the moment Thanks anyway! Stef ---(end of broadca

Re: [GENERAL] ORDER BY - problem with NULL values

2007-10-10 Thread Rodrigo Gonzalez
Richard Huxton escribió: Stefan Schwarzer wrote: Hi there, if I order a given year in DESCending ORDER, so that the highest values (of a given variable) for the countries are displayed at the top of the list, then actually the NULL values appear as first. Only below, I find the values ordered

Re: [GENERAL] ORDER BY - problem with NULL values

2007-10-10 Thread Richard Huxton
Stefan Schwarzer wrote: Hi there, if I order a given year in DESCending ORDER, so that the highest values (of a given variable) for the countries are displayed at the top of the list, then actually the NULL values appear as first. Only below, I find the values ordered correctly. Is there any

Re: [GENERAL] ORDER BY - problem with NULL values

2007-10-10 Thread Stefan Schwarzer
Hi there, if I order a given year in DESCending ORDER, so that the highest values (of a given variable) for the countries are displayed at the top of the list, then actually the NULL values appear as first. Only below, I find the values ordered correctly. Is there any way to a) make the

Re: [GENERAL] ORDER BY - problem with NULL values

2007-10-10 Thread Richard Huxton
Stefan Schwarzer wrote: Hi there, if I order a given year in DESCending ORDER, so that the highest values (of a given variable) for the countries are displayed at the top of the list, then actually the NULL values appear as first. Only below, I find the values ordered correctly. Is there an

[GENERAL] ORDER BY - problem with NULL values

2007-10-10 Thread Stefan Schwarzer
Hi there, if I order a given year in DESCending ORDER, so that the highest values (of a given variable) for the countries are displayed at the top of the list, then actually the NULL values appear as first. Only below, I find the values ordered correctly. Is there any way to a) make t

[GENERAL] ORDER BY on multiple columns still requires multi-col index?

2007-08-04 Thread pritchard . adam
Does this change... --- Allow index scans to use an intermediate in-memory bitmap (Tom) In previous releases, only a single index could be used to do lookups on a table. With this feature, if a query has WHERE tab.col1 = 4 and tab.col2 = 9, and there is no multicolumn index on col1 and col2, b

Re: [GENERAL] ORDER BY with exception

2007-06-22 Thread Erik Jones
On Jun 21, 2007, at 8:08 PM, brian wrote: Michael Glaesemann wrote: On Jun 21, 2007, at 17:35 , brian wrote: I have a lookup table with a bunch of disciplines: To answer your ordering question first: SELECT id, name FROM discipline ORDER BY name = 'other' , name; id |name +--

Re: [GENERAL] ORDER BY with exception

2007-06-21 Thread brian
Michael Glaesemann wrote: On Jun 21, 2007, at 17:35 , brian wrote: I have a lookup table with a bunch of disciplines: To answer your ordering question first: SELECT id, name FROM discipline ORDER BY name = 'other' , name; id |name +- 8 | community 4 |

Re: [GENERAL] ORDER BY with exception

2007-06-21 Thread brian
Josh Tolley wrote: It seems to me you could replace it all with one query, something like this: SELECT discipline, COUNT(1) FROM showcase WHERE EXISTS (SELECT * FROM showcase_item WHERE showcase_id = showcase.id LIMIT 1) GROUP BY discipline ORDER BY (discipline != 'other'), discipline; disci

Re: [GENERAL] ORDER BY with exception

2007-06-21 Thread Michael Glaesemann
On Jun 21, 2007, at 17:35 , brian wrote: I have a lookup table with a bunch of disciplines: To answer your ordering question first: SELECT id, name FROM discipline ORDER BY name = 'other' , name; id |name +- 8 | community 4 | dance 5 | film and telev

Re: [GENERAL] ORDER BY with exception

2007-06-21 Thread Josh Tolley
On 6/21/07, brian <[EMAIL PROTECTED]> wrote: I have a lookup table with a bunch of disciplines: # SELECT id, name FROM discipline; id |name +- 1 | writing 2 | visual arts 3 | music 4 | dance 5 | film and television 6 | theatre 7 | media arts

[GENERAL] ORDER BY with exception

2007-06-21 Thread brian
I have a lookup table with a bunch of disciplines: # SELECT id, name FROM discipline; id |name +- 1 | writing 2 | visual arts 3 | music 4 | dance 5 | film and television 6 | theatre 7 | media arts 8 | community 9 | fine craft 10 | other (10 rows

[GENERAL] ORDER BY with UNION

2007-04-11 Thread Niederland
Using Postgresql 8.2.3 The following query functions correctly: select lastname as name from person where lastname ='Smith' union select firstname as name from person where firstname = 'John' order by name; --- The followi

Re: RES: [GENERAL] Order by behaviour

2007-04-06 Thread Martijn van Oosterhout
On Thu, Apr 05, 2007 at 06:46:27PM -0300, Carlos H. Reimer wrote: > Hi, > > I was trying to find the docs about the collating sequence standards but > could not find. > > Would like to know for example which characters are ignored by the "order > by" in some of the collating types. There are no

RES: [GENERAL] Order by behaviour

2007-04-05 Thread Carlos H. Reimer
standards? Thanks in advance! > -Mensagem original- > De: Stephan Szabo [mailto:[EMAIL PROTECTED] > Enviada em: quarta-feira, 28 de março de 2007 19:23 > Para: Carlos H. Reimer > Cc: pgsql-general@postgresql.org > Assunto: Re: [GENERAL] Order by behaviour > > > On Wed

Re: RES: [GENERAL] Order by behaviour

2007-03-29 Thread Stephan Szabo
On Thu, 29 Mar 2007, Carlos H. Reimer wrote: > Humm, ok, it is clear now. > > And is there a way to change something in this behaviour, like not ignore > spaces and some type of symbols? Well, right now it's generally determined by your OS's definition of the locale you've chosen. You might be ab

Re: RES: [GENERAL] Order by behaviour

2007-03-29 Thread Richard Huxton
Carlos H. Reimer wrote: Humm, ok, it is clear now. And is there a way to change something in this behaviour, like not ignore spaces and some type of symbols? A configuration file or a patch? Pick a different locale? -- Richard Huxton Archonet Ltd ---(end of broad

RES: [GENERAL] Order by behaviour

2007-03-29 Thread Carlos H. Reimer
han Szabo > Enviada em: quarta-feira, 28 de março de 2007 19:23 > Para: Carlos H. Reimer > Cc: pgsql-general@postgresql.org > Assunto: Re: [GENERAL] Order by behaviour > > > On Wed, 28 Mar 2007, Carlos H. Reimer wrote: > > > Hi, > > > > We have a PostgreSQL 8.0

Re: [GENERAL] Order by behaviour

2007-03-28 Thread Stephan Szabo
On Wed, 28 Mar 2007, Carlos H. Reimer wrote: > Hi, > > We have a PostgreSQL 8.0.6 cluster configured with lc_collate=pt_BR.UTF-8 > and when we run the following SELECT: > SELECT substr(nomerazao,1,4), > ascii(substr(nomerazao,1,1)), > ascii(substr(nomerazao,2,1)) > from spunico.unico order by nome

Re: [GENERAL] Order by behaviour

2007-03-28 Thread Peter Eisentraut
Carlos H. Reimer wrote: > Are not the lines out of order No. > or is it a normal behaviour for a > server with lc_collate=pt_BR.UTF-8? Yes. -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---(end of broadcast)--- TIP 2: Don't 'kill

Re: [GENERAL] Order by behaviour

2007-03-28 Thread Raymond O'Donnell
On 28/03/2007 22:52, Carlos H. Reimer wrote: SELECT substr(nomerazao,1,4), ascii(substr(nomerazao,1,1)), ascii(substr(nomerazao,2,1)) from spunico.unico order by nomerazao; You need to add aliases to the returned column by which you'd like to order the result: your query is ordering the rows

[GENERAL] Order by behaviour

2007-03-28 Thread Carlos H. Reimer
Hi, We have a PostgreSQL 8.0.6 cluster configured with lc_collate=pt_BR.UTF-8 and when we run the following SELECT: SELECT substr(nomerazao,1,4), ascii(substr(nomerazao,1,1)), ascii(substr(nomerazao,2,1)) from spunico.unico order by nomerazao; is returning: substr | ascii | ascii +-

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-12 Thread Bruce Momjian
Alvaro Herrera wrote: > Bruce Momjian wrote: > > > Here the column result is an expression, and you reference that. > > Updated wording: > > > > test=> select * from test union select * from test order by x is null; > > ERROR: A UNION/INTERSECT/EXCEPT ORDER BY cannot use expressions or > > f

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-11 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Where are the style guidelines? I looked before but can't find them. http://developer.postgresql.org/pgdocs/postgres/error-style-guide.html regards, tom lane ---(end of broadcast)

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-11 Thread Bruce Momjian
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > Updated wording: > > > test=> select * from test union select * from test order by x is null; > > ERROR: A UNION/INTERSECT/EXCEPT ORDER BY cannot use expressions or > > functions, only result column names > > This does not meet t

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-11 Thread Alvaro Herrera
Bruce Momjian wrote: > Here the column result is an expression, and you reference that. > Updated wording: > > test=> select * from test union select * from test order by x is null; > ERROR: A UNION/INTERSECT/EXCEPT ORDER BY cannot use expressions or > functions, only result column names Th

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-11 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Updated wording: > test=> select * from test union select * from test order by x is null; > ERROR: A UNION/INTERSECT/EXCEPT ORDER BY cannot use expressions or > functions, only result column names This does not meet the style guidelines.

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-11 Thread Bruce Momjian
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > Well, it can be an expression _if_ the expression _matches_ an existing > > UNION column. > > You're mistaken. It has to be *an output column name*. Not anything else. Yea, I was thinking of this: SELECT *, state IS NULL A

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-11 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > Well, it can be an expression _if_ the expression _matches_ an existing > UNION column. You're mistaken. It has to be *an output column name*. Not anything else. regards, tom lane ---(end of broadcast)-

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-11 Thread Bruce Momjian
Mike Benoit wrote: > That helps some, but I'm sure it could be even more clear. > > The main issue is that you can't order by an expression computed by > unions, correct? So couldn't the error message by something like: > > "ORDER BY on a UNION/INTERSECT/EXCEPT result must match existing result

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-11 Thread Mike Benoit
On Thu, 2007-01-11 at 13:44 -0500, Bruce Momjian wrote: > Tom Lane wrote: > > Michael Glaesemann <[EMAIL PROTECTED]> writes: > > > On Dec 26, 2006, at 18:39 , Mike Benoit wrote: > > >> ERROR: ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of > > >> the result columns > > > > > Even th

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2007-01-11 Thread Bruce Momjian
Tom Lane wrote: > Michael Glaesemann <[EMAIL PROTECTED]> writes: > > On Dec 26, 2006, at 18:39 , Mike Benoit wrote: > >> ERROR: ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of > >> the result columns > > > Even though state is a column in both tables, the order by is using > > an

Re: [GENERAL] ORDER BY col is NULL in UNION causes error?

2006-12-26 Thread Tom Lane
Michael Glaesemann <[EMAIL PROTECTED]> writes: > On Dec 26, 2006, at 18:39 , Mike Benoit wrote: >> ERROR: ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of >> the result columns > Even though state is a column in both tables, the order by is using > an expression, rather than a colu

  1   2   >