Re: [SQL] Listing table definitions by only one command

2013-07-17 Thread Wes James
On Wed, Jul 17, 2013 at 9:29 AM, Carla Goncalves cgourof...@hotmail.comwrote: Hi I would like to list the definition of all user tables by only one command. Is there a way to *not* show pg_catalog tables when using \d . in PostgreSQL 9.1.9? Thanks. I didn't see a way to do that with \

[SQL] deciding on one of multiple results returned

2012-12-21 Thread Wes James
If a query returns, say the following results: id value 0 a 0 b 0 c 1 a 1 b How do I just choose a preferred element say value 'a' over any other elements returned, that is the value returned is from a subquery to a larger query? Thanks.

Re: [SQL] deciding on one of multiple results returned

2012-12-21 Thread Wes James
DISTINCT ON (id) ... ORDER BY value”. The database will sort the query results before running them through the DISTINCT filter. On Fri, Dec 21, 2012 at 11:31 AM, Wes James compte...@gmail.com wrote: If a query returns, say the following results: id value 0 a 0 b 0 c 1

Re: [SQL] deciding on one of multiple results returned

2012-12-21 Thread Wes James
Thanks. I was testing different things and I came up with something similar to that. I appreciate you taking time to answer. On Fri, Dec 21, 2012 at 11:22 AM, Scott Marlowe scott.marl...@gmail.comwrote: On Fri, Dec 21, 2012 at 10:28 AM, Wes James compte...@gmail.com wrote: David and Seth

Re: [SQL] Simple method to format a string

2012-06-20 Thread Wes James
On Wed, Jun 20, 2012 at 8:42 AM, Emi Lu em...@encs.concordia.ca wrote: Good morning, Is there a simply method in psql to format a string? For example, adding a space to every three consecutive letters: abcdefgh - *** *** *** Thanks a lot! Emi I looked at format here:

Re: [SQL] order by different on mac vs linux

2012-05-26 Thread Wes James
On Mon, May 14, 2012 at 4:42 PM, Wes James compte...@gmail.com wrote: I have postgresql 9.1.3 on a mac and on linux. On the mac the results come out: ! *`-=[];',./~@#$%^()_+{}|:?\ then \--\ On ubuntu 12.04 x64 it comes out (compiled and installed postgres from tbz2 from postgresql.org

Re: [SQL] order by different on mac vs linux

2012-05-26 Thread Wes James
Back to the drawing board. Windows sorts these lines thus (postgresql 9.1.3): ! *`-=[];',./~@#$%^()_+{}|:?\ !! !a !A !B !ia !test \--\ African agricultural research and technological development on the ascii table here: http://www.ascii-code.com/ upper case letters should sort before

Re: [SQL] order by different on mac vs linux

2012-05-16 Thread Wes James
On Mon, May 14, 2012 at 5:00 PM, Tom Lane t...@sss.pgh.pa.us wrote: Wes James compte...@gmail.com writes: Why is there a different order on the different platforms. This is not exactly unusual. You should first check to see if lc_collate is set differently in the two installations

Re: [SQL] order by different on mac vs linux

2012-05-16 Thread Wes James
On Wed, May 16, 2012 at 5:00 PM, Samuel Gendler sgend...@ideasculptor.comwrote: On Wed, May 16, 2012 at 3:46 PM, Wes James compte...@gmail.com wrote: On Mon, May 14, 2012 at 5:00 PM, Tom Lane t...@sss.pgh.pa.us wrote: Wes James compte...@gmail.com writes: Why is there a different order

Re: [SQL] order by different on mac vs linux

2012-05-15 Thread Wes James
On Mon, May 14, 2012 at 5:00 PM, Tom Lane t...@sss.pgh.pa.us wrote: Wes James compte...@gmail.com writes: Why is there a different order on the different platforms. This is not exactly unusual.  You should first check to see if lc_collate is set differently in the two installations

Re: [SQL] order by different on mac vs linux

2012-05-15 Thread Wes James
On Mon, May 14, 2012 at 5:00 PM, Tom Lane t...@sss.pgh.pa.us wrote: Wes James compte...@gmail.com writes: Why is there a different order on the different platforms. This is not exactly unusual.  You should first check to see if lc_collate is set differently in the two installations

Re: [SQL] order by different on mac vs linux

2012-05-15 Thread Wes James
On Mon, May 14, 2012 at 5:00 PM, Tom Lane t...@sss.pgh.pa.us wrote: Wes James compte...@gmail.com writes: Why is there a different order on the different platforms. This is not exactly unusual.  You should first check to see if lc_collate is set differently in the two installations

Re: [SQL] order by different on mac vs linux

2012-05-15 Thread Wes James
On Tue, May 15, 2012 at 10:16 AM, Scott Marlowe scott.marl...@gmail.com wrote: On Tue, May 15, 2012 at 10:06 AM, Wes James compte...@gmail.com wrote: On Mon, May 14, 2012 at 5:00 PM, Tom Lane t...@sss.pgh.pa.us wrote: Wes James compte...@gmail.com writes: Why is there a different order

[SQL] order by different on mac vs linux

2012-05-14 Thread Wes James
I have postgresql 9.1.3 on a mac and on linux. On the mac the results come out: ! *`-=[];',./~@#$%^()_+{}|:?\ then \--\ On ubuntu 12.04 x64 it comes out (compiled and installed postgres from tbz2 from postgresql.org repo): \--\ then ! *`-=[];',./~@#$%^()_+{}|:?\ Why is there a different

Re: [SQL] Finding Max Value in a Row

2012-05-11 Thread Wes James
On Fri, May 11, 2012 at 1:03 PM, Carlos Mennens carlos.menn...@gmail.com wrote: I have a problem in SQL I don't know how to solve and while I'm sure there are 100+ ways to do this in ANSI SQL, I'm trying to find the most cleanest / efficient way. I have a table called 'users' and the field

Re: [SQL] why these results?

2011-08-02 Thread Wes James
Yes. Thanks to all that responded. That was it. -wes On Mon, Aug 1, 2011 at 5:01 PM, Steve Crawford scrawf...@pinpointresearch.com wrote: On 08/01/2011 03:50 PM, Wes James wrote: select count(*) from table; count ---    100 (1 row) is correct select count(*) from table where

[SQL] why these results?

2011-08-01 Thread Wes James
select count(*) from table; count --- 100 (1 row) is correct select count(*) from table where col::text ~~* '%text%'; count --- 1 (1 row) is correct. But now if I do: select count(*) from table where col::text !~~* '%text%'; count --- 98 (1 row) Shouldn't it be 99?

Re: [SQL] combining strings to make a query

2011-07-13 Thread Wes James
of the string you are searching forIt appears to be much faster from my experience to search for ab% than it is to search for %ab%. On Tue, Jul 12, 2011 at 7:51 PM, Wes James compte...@gmail.com wrote: I'm using Erlang and postgresql to build a web interface.  When I create the query string I get

Re: [SQL] Looking for a show create table name equivalent

2011-07-13 Thread Wes James
On Tue, Jul 12, 2011 at 2:33 AM, B.Rathmann b.rathm...@ping.de wrote: Hello, I've been trying to find out how to find out which sql was run to create a certain table. As I need this in a program which may access the database remotely, using pg_dump --schema-only or psql is not an option

Re: [SQL] Looking for a show create table name equivalent

2011-07-13 Thread Wes James
On Tue, Jul 12, 2011 at 2:33 AM, B.Rathmann b.rathm...@ping.de wrote: Hello, I've been trying to find out how to find out which sql was run to create a certain table. As I need this in a program which may access the database remotely, using pg_dump --schema-only or psql is not an option (the

[SQL] combining strings to make a query

2011-07-12 Thread Wes James
I'm using Erlang and postgresql to build a web interface. When I create the query string I get something like: select * from table where field::text ilike '%%' But when I do that (if someone types in '\' for part of the text search), I get a pg log entry to use E'\\' How would I use E''

[SQL] how to escape _ in select

2010-07-28 Thread Wes James
I'm trying to do this: select * from table where field::text ilike '%\_%'; but it doesn't work. How do you escape the _ and $ chars? The docs say to use \, but that isn't working. ( http://www.postgresql.org/docs/8.3/static/functions-matching.html ) The text between '%...%' can be longer,

Re: [SQL] how to escape _ in select

2010-07-28 Thread Wes James
On Wed, Jul 28, 2010 at 12:47 PM, Justin Graf jus...@magwerks.com wrote: On 7/28/2010 12:35 PM, Wes James wrote: I'm trying to do this: select * from table where field::text ilike '%\_%'; but it doesn't work. How do you escape the _ and $ chars? The docs say to use \, but that isn't

Re: [SQL] how to escape _ in select

2010-07-28 Thread Wes James
Thanks Douglas and Tom - I missed that second \. -wes -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] how to escape _ in select

2010-07-28 Thread Wes James
On Wed, Jul 28, 2010 at 12:15 PM, Little, Douglas douglas.lit...@orbitz.com wrote: Wes. You probably missed the part in bold.   You need to double the backslash. select 'ab5c' like '%\_c' t Why doesn't this work? select * from table where field::text ilike '%\\\%' WARNING: nonstandard

Re: [SQL] sum an alias

2010-06-04 Thread Wes James
On Thu, Jun 3, 2010 at 11:54 PM, A. Kretschmer andreas.kretsch...@schollglas.com wrote: In response to Wes James : In the statement: select     MAX(page_count_count) - MIN(page_count_count) as day_tot,     MAX(page_count_count) as day_max, sum(MAX(page_count_count) - MIN(page_count_count

[SQL] sum an alias

2010-06-03 Thread Wes James
In the statement: select MAX(page_count_count) - MIN(page_count_count) as day_tot, MAX(page_count_count) as day_max, sum(MAX(page_count_count) - MIN(page_count_count)) as tot, page_count_pdate from page_count group by page_count_pdate order by page_count_pdate Is there a way to do

[SQL] how to construct sql

2010-06-02 Thread Wes James
I am grabbing a printer total and putting it in a table. The page_count is continuously increasing: page_count_countpage_count_pdate 10 2010-05-10 20 2010-05-10 40 2010-05-11 60

Re: [SQL] how to construct sql

2010-06-02 Thread Wes James
On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros oliveiros.crist...@marktest.pt wrote: Hi, Have you already tried this out? select MAX(page_count_count) - MIN(page_count_count)  from page_count group by page_count_pdate. Best, Oliveiros Oliveiros, Thx that mostly works. I just tried it and

Re: [SQL] how to construct sql

2010-06-02 Thread Wes James
On Wed, Jun 2, 2010 at 2:44 PM, Justin Graf jus...@magwerks.com wrote: On 6/2/2010 12:31 PM, Wes James wrote: On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros oliveiros.crist...@marktest.pt  wrote: Hi, Have you already tried this out? select MAX(page_count_count) - MIN(page_count_count)  from

[SQL] how to do this query

2010-01-08 Thread Wes James
I have two tables: students stu_name schols_selected scholarships schol_name short_name schols_selected is made up of scholarships the students have selected, the field content will look like schol1:schol2:schol3 I need a select that does something like this select schol_name,