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 wrote: > 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 \ commands, but fou

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 wrote: > On Fri, Dec 21, 2012 at 10:28 AM, Wes James wrote: > > David and Seth Thanks. That helped. > &g

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

2012-12-21 Thread Wes James
be “SELECT 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 wrote: > >> If a query returns, say the following results: >> >> id va

[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] Simple method to format a string

2012-06-20 Thread Wes James
On Wed, Jun 20, 2012 at 8:42 AM, Emi Lu 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: http://www.postgresql.org

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

2012-05-31 Thread Wes James
On Mon, May 14, 2012 at 5:00 PM, Tom Lane wrote: > Wes James 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 --- but even if >

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 lower

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 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 a

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 wrote: > > > On Wed, May 16, 2012 at 3:46 PM, Wes James wrote: > >> >> >> On Mon, May 14, 2012 at 5:00 PM, Tom Lane wrote: >> >>> Wes James writes: >>> > Why is there a different orde

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 wrote: > Wes James 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 --- but even if >

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 wrote: > On Tue, May 15, 2012 at 10:06 AM, Wes James wrote: >> On Mon, May 14, 2012 at 5:00 PM, Tom Lane wrote: >>> Wes James writes: >>>> Why is there a different order on the different platforms. >>> >&

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 wrote: > Wes James 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 --- but even if >

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 wrote: > Wes James 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 --- but even if >

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 wrote: > Wes James 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 --- but even if >

[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 dif

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 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 'users_id' is listed as

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 wrote: > On 08/01/2011 03:50 PM, Wes James wrote: >> >> select count(*) from table; >> >> count >> --- >>    100 >> (1 row) >> >>

[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] Looking for a "show create table " equivalent

2011-07-13 Thread Wes James
On Tue, Jul 12, 2011 at 2:33 AM, B.Rathmann 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 system my pr

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

2011-07-13 Thread Wes James
On Tue, Jul 12, 2011 at 2:33 AM, B.Rathmann 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 Maybe turning on

Re: [SQL] combining strings to make a query

2011-07-13 Thread Wes James
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 wrote: >> I'm using Erlang and postgresql to build a web interface.  When I >> create 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'' wit

Re: [SQL] how to escape _ in select

2010-07-28 Thread Wes James
On Wed, Jul 28, 2010 at 12:15 PM, Little, Douglas 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 use of \\ in a str

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:47 PM, Justin Graf 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 esca

[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, I'm

Re: [SQL] sum an alias

2010-06-04 Thread Wes James
On Thu, Jun 3, 2010 at 11:54 PM, A. Kretschmer 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) -

[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 sum

Re: [SQL] how to construct sql

2010-06-02 Thread Wes James
On Wed, Jun 2, 2010 at 1:51 PM, Plugge, Joe R. wrote: > This is discussed in this Wiki: > > > http://wiki.postgresql.org/wiki/Grouping_Sets > This would sum the results and would be incorrect. I also get this error: select sum(page_count_count), page_count_pdate from page_count group by rollup(

Re: [SQL] how to construct sql

2010-06-02 Thread Wes James
On Wed, Jun 2, 2010 at 2:44 PM, Justin Graf wrote: > On 6/2/2010 12:31 PM, Wes James wrote: >> On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros >>  wrote: >> >>> Hi, >>> Have you already tried this out? >>> >>> select MAX(page_count_cou

Re: [SQL] how to construct sql

2010-06-02 Thread Wes James
On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros 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 on the days there is on

[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

[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, short_na