Re: [SQL] the use of $$string$$

2011-11-07 Thread Peter Eisentraut
On mån, 2011-11-07 at 08:44 +, Richard Huxton wrote: > > myvarString = "long string that contains single quotes" > > cusor.execute("insert into table (pkid, myfield) values (%s, $$%s > $$)",(123, > > myvarString)) > > > > When I execute the above I'm seeing: > > E'long string that contains sing

Re: [SQL] GROUP and ORDER BY

2011-11-07 Thread Robins Tharakan
Unless I overlooked something here, does this work ? SELECT no, name, MAX(similarity(name, 'Tooneyvara')) AS sim FROM vtown WHERE similarity(name, 'Tooneyvara') > 0.4 GROUP BY no, name ORDER BY sim DESC -- Robins Tharakan On 11/08/2011 02:50 AM, Tarlika Elisabeth Schmitz wrote: Hello, I would

[SQL] GROUP and ORDER BY

2011-11-07 Thread Tarlika Elisabeth Schmitz
Hello, I would like to GROUP the result by one column and ORDER it by another: SELECT no, name, similarity(name, 'Tooneyvara') AS s FROM vtown WHEREsimilarity(name, 'Tooneyvara') > 0.4 ORDER BY s DESC Result: 1787"Toomyvara" 0.5 1787"Toomevara" 0.4 1188

Re: [SQL] How to implement Aggregate Awareness?

2011-11-07 Thread Little, Douglas
Olgierd, This can be done, but it relies on a very strong metadata component that is not available in PG. In db2eee it's completed by having a construct known as automatic summary tables - similar to materialized views Where in ddl you tell the system how the aggregate and base table are related

Re: [SQL] How to implement Aggregate Awareness?

2011-11-07 Thread Olgierd Michalak
> Simply put, when Transparent (to the reporting tool) Aggregate Navigator > recognizes that a query would execute faster using aggregates, it > automatically rewrites the query so that the database hits the smaller > aggregates rather than larger detail tables upon which the small > aggregates are

Re: [SQL] the use of $$string$$

2011-11-07 Thread Richard Huxton
On 05/11/11 00:12, John Fabiani wrote: I'm using psycopg2. OK - bear in mind, I'm not a Python user. This is what I'm doing from python myvarString = "long string that contains single quotes" cusor.execute("insert into table (pkid, myfield) values (%s, $$%s$$)",(123, myvarString)) When I exe