Re: [SQL] Combining several CTEs with a recursive CTE

2011-09-20 Thread Thomas Kellerer
David Johnston, 20.09.2011 16:15: I'm just wondering if this is intended behavioury, simply not (yet) implemented or even invalid according to the standard? I didn't find any reference that it's not allowed in the manual. Regards Thomas Try sticking the recursive keyword after the "with" if a

Re: [SQL] Combining several CTEs with a recursive CTE

2011-09-20 Thread David Johnston
On Sep 20, 2011, at 5:58, Thomas Kellerer wrote: > > I'm just wondering if this is intended behavioury, simply not (yet) > implemented or even invalid according to the standard? I didn't find any > reference that it's not allowed in the manual. > > Regards > Thomas > > Try sticking the rec

[SQL] Combining several CTEs with a recursive CTE

2011-09-20 Thread Thomas Kellerer
Hello all, this is more a "just curious" question, rather than a real world problem. We can combine several CTEs into a single select using something like this: WITH cte_1 as ( select ), cte_2 as ( select ... where id (select some_col from cte_1) ) select * from cte_2; But this

Re: [SQL] combining strings to make a query

2011-07-13 Thread Wes James
Thank you for the tsvectors info! -wes On Wed, Jul 13, 2011 at 12:11 AM, Kevin Crain wrote: > You can do full-text search in postgres now using ts_vectors.  I'd > recommend going that route.  Doing like comparisons is not a good idea > if you don't know the first part of the string you are searc

Re: [SQL] combining strings to make a query

2011-07-12 Thread Kevin Crain
You can do full-text search in postgres now using ts_vectors. I'd recommend going that route. Doing like comparisons is not a good idea if you don't know the first part of the string you are searching forIt appears to be much faster from my experience to search for ab% than it is to search fo

[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] combining records from a single table and presenting them as one record

2005-10-28 Thread Michael Fuhr
On Fri, Oct 28, 2005 at 11:47:12AM -0400, Abhishek wrote: > Using LIMIT 1 does return me a single record but please note that the table > can have multiple guids for which I need a unique record with all the digit > types combined. Using LIMIT 1 returns me always one record. :-( Have you looked at

Re: [SQL] combining records from a single table and presenting them as one record

2005-10-28 Thread Abhishek
Using LIMIT 1 does return me a single record but please note that the table can have multiple guids for which I need a unique record with all the digit types combined. Using LIMIT 1 returns me always one record. :-( On 10/27/05, boinger <[EMAIL PROTECTED]> wrote: On 10/27/05, Abhishek <[EMAIL PROT

Re: [SQL] combining records from a single table and presenting

2005-10-27 Thread Frank Bax
At 02:00 PM 10/27/05, Abhishek wrote: I have a table "TABLE1" which has Callguid | digits | type 123 'a' 345

Re: [SQL] combining records from a single table and presenting them as one record

2005-10-27 Thread boinger
On 10/27/05, Abhishek <[EMAIL PROTECTED]> wrote: > I am tryng to write a query which returns me a record like this > I do the query as this: > > select callguid , ( select digits from TABEL1 where type='a' ), ( select > digits from TABEL1 where type='b' ), ( select digits from TABEL1 where > type=

[SQL] combining records from a single table and presenting them as one record

2005-10-27 Thread Abhishek
Hi Everyone   I have a table "TABLE1"  which has Callguid  |   digits |  type    123   'a'    345   'b'  

Re: [SQL] Combining two SELECTs by same filters

2005-10-26 Thread Bruno Wolff III
On Wed, Oct 26, 2005 at 18:16:13 +0300, Volkan YAZICI <[EMAIL PROTECTED]> wrote: > And I want to collect the count of sales at hour = 21 and hour = 22. > For this purpose, I'm using below SELECT query: > > => SELECT > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND

Re: [SQL] Combining two SELECTs by same filters

2005-10-26 Thread Michael Fuhr
On Wed, Oct 26, 2005 at 06:16:13PM +0300, Volkan YAZICI wrote: > => SELECT > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND date_trunc('hour', dt) = '2005-10-25 21:00:00'), > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND date_trunc('h

Re: [SQL] Combining two SELECTs by same filters

2005-10-26 Thread Scott Marlowe
On Wed, 2005-10-26 at 10:16, Volkan YAZICI wrote: > => SELECT > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND date_trunc('hour', dt) = '2005-10-25 21:00:00'), > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND date_trunc('hour', dt) =

[SQL] Combining two SELECTs by same filters

2005-10-26 Thread Volkan YAZICI
Hi, I've a table like: => SELECT dt FROM sales WHERE id = 2; dt 2005-10-25 21:43:35.870049 2005-10-25 21:43:36.254122 2005-10-25 21:43:36.591196 2005-10-25 21:43:36.893331 2005-10-25 21:43:37.265671 2005-10-25 21:43:37.688186 2005-10-25 22:25:35.2131

Re: [SQL] Combining values in a column

2005-04-15 Thread Sean Davis
See below for creating aggregates: http://www.postgresql.org/docs/current/static/xaggr.html But, there is a useful function built-in, bit_and, that does what you want: http://www.postgresql.org/docs/current/static/functions- aggregate.html#FUNCTIONS-AGGREGATE-TABLE create table testint (

[SQL] Combining values in a column

2005-04-15 Thread Stephen Quinney
I have a query which returns a single column of integers which I want to combine together with &, "bitwise AND". Basically it's a simple list of access levels that a user might have and I want to merge the list into one value. There can be zero, one or more values in the list so I have to be able t

Re: [SQL] Combining queries while preserving order in SQL - Help!

2002-12-02 Thread Joel Burton
On Mon, Dec 02, 2002 at 01:46:38PM -0500, Casey Allen Shobe wrote: > Hi there, > > I need to do the following in one SQL query: > > select field1, field2, field3, field4, field5 from table where field6 < 5 > order by field1 > > And a totals line which shows the sum for each column. > > The impo

[SQL] Combining queries while preserving order in SQL - Help!

2002-12-02 Thread Casey Allen Shobe
Hi there, I need to do the following in one SQL query: select field1, field2, field3, field4, field5 from table where field6 < 5 order by field1 And a totals line which shows the sum for each column. The important part is that I need to preserve the order by of the first query. Is there any wa

Re: [SQL] combining

2001-02-12 Thread Peter Eisentraut
Frank Morton writes: > These two queries get me what I want from each table: > > select unique id from table1 where lastname='morton'; > select unique id from table2 where ((type = "pie") and (content = 'apple)); > > What is the best way to combine these into one query? select table1.id from tab

Re: [SQL] combining

2001-02-12 Thread Jie Liang
Jie LIANG St. Bernard Software Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 [EMAIL PROTECTED] www.stbernard.com www.ipinc.com On Mon, 12 Feb 2001, Frank Morton wrote: > I'll really appreciate help on this if anyone will do so. I'm > u

[SQL] combining

2001-02-12 Thread Frank Morton
I'll really appreciate help on this if anyone will do so. I'm used to single-table stuff, but not sure the best way to do things with multiple tables, but here goes: Given two tables with a common "id" field, first table columns: id lastname Second table columns: id type content These two que