Re: [SQL] How to right justify text in psql?

2013-05-17 Thread Ian Lawrence Barwick
2013/5/18 Brian Sherwood : > I am running postgresql 9.2. > > I am assuming it would be a function of psql to right justify text, but I > can't find any way to do this. > > Is there a way to right justify just one text column? If you mean have the psql client right-justify a particular text column

Re: [SQL] Update HSTORE record and then delete if it is now empty - What is the correct sql?

2013-02-22 Thread Ian Lawrence Barwick
2013/2/23 Ashwin Jayaprakash : (...) > > Q2: What the best way to check if an HSTORE is empty? Is this it > "array_length(akeys(data), 1) is null"? Just a quick answer to your second question: I suspect it might be more efficient to check your HSTORE column against an empty HSTORE, e.g. WHERE v

Re: [SQL] Setting a default value for a select statement without results

2013-02-05 Thread Ian Lawrence Barwick
2013/2/6 JORGE MALDONADO : > I have an UPDATE query with the following general structure: > > UPDATE table1 SET (SELECT field FROM table2 WHERE conditions ORDER BY > order_field LIMIT 1) > > Is it possible to assign a default value in case no results are returned by > the SELECT statement? One opt

Re: [SQL] Problem with extract(epoch from interval ...

2013-01-23 Thread Ian Lawrence Barwick
Hi 2013/1/23 Kaloyan Iliev : > Hi, > I have a little problem with extract epoch from interval. It seems that the > query works if the interval is in a string but not from DB field. > Could someone provide support. (...) You have a casting error; instead of: > dbr=# SELECT extract(EPOCH FROM INT

Re: [SQL] self join

2011-05-14 Thread Ian Lawrence Barwick
icit join and is producing a cartesian result. I don't think a self- join will work here; a subquery should produce the result you're after: SELECT * FROM tmp t1 WHERE NOT EXISTS(SELECT TRUE FROM tmp t2 WHERE t2.b=t1.a); HTH Ian Lawrence Barwick -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql