Re: [SQL] How can I selet rows which have 2 columns values cross equal?

2006-03-11 Thread Michael Glaesemann
On Mar 11, 2006, at 16:46 , Michael Glaesemann wrote: select t1.id as t1_id, t2.id as t2_id from test t1 join test t2 on (t1.a = t2.b and t1.b = t2.a) where t1.a < t2.a; t1_id | t2_id ---+--- 4 | 7 1 | 2 (2 rows) Just a follow-up (mostly to myself): I've been toying

[SQL] input from a external text file......!

2006-03-11 Thread AKHILESH GUPTA
Hi All.! I just want to know one thing that is it possible with PGSQL that, if I want to insert and execute a query from a external text file instead of giving it at the pgsql prompt? just like in Oracle the file having query is executed with a '@ filename' statement at the sql prompt..

Re: [SQL] input from a external text file......!

2006-03-11 Thread Andreas Kretschmer
AKHILESH GUPTA <[EMAIL PROTECTED]> schrieb: > Hi All.! > I just want to know one thing that is it possible with PGSQL that, > if I want to insert and execute a query from a external text file instead of > giving it at the pgsql prompt? in psql, try simple "\i your_file.sql" to execute the

Re: [SQL] input from a external text file......!

2006-03-11 Thread PFC
inside psql, type : \i filename On Sat, 11 Mar 2006 11:29:20 +0100, AKHILESH GUPTA <[EMAIL PROTECTED]> wrote: Hi All.! I just want to know one thing that is it possible with PGSQL that, if I want to insert and execute a query from a external text file instead of giving it at t

[SQL] Merging rows into one result?

2006-03-11 Thread Jesper K. Pedersen
Is it possible to use SQL to merge data into one result? A theorethical example to explain: tbl_test ( id integer, information varchar(25)) id | information ---+-- 1 | Yo 2 | Go away 1 | Stay put 3 | Greetings Please note id is not unique and not a primary key. and I wonder

Re: [SQL] Merging rows into one result?

2006-03-11 Thread Andreas Kretschmer
Jesper K. Pedersen <[EMAIL PROTECTED]> schrieb: > Is it possible to use SQL to merge data into one result? > > A theorethical example to explain: > > tbl_test ( > id integer, > information varchar(25)) > > id | information > ---+-- > 1 | Yo > 2 | Go away > 1 | Stay put > 3 |

Re: [SQL] Merging rows into one result?

2006-03-11 Thread Volkan YAZICI
Hi, On Mar 11 05:31, Jesper K. Pedersen wrote: > Is it possible to use SQL to merge data into one result? test=# SELECT id, info FROM concat_t; id | info +-- 1 | A 2 | B 1 | AA 3 | C 1 | D 1 | DD (6 rows) test=# SELECT array_to_string(ARRAY(SELECT info FROM concat_t WHERE i

Re: [SQL] Merging rows into one result?

2006-03-11 Thread Jesper K. Pedersen
On Sat, 11 Mar 2006 17:43:37 +0100 Andreas Kretschmer <[EMAIL PROTECTED]> wrote: > Jesper K. Pedersen <[EMAIL PROTECTED]> schrieb: > > > Is it possible to use SQL to merge data into one result? > > > > A theorethical example to explain: > > > > tbl_test ( > > id integer, > > information var

Re: [SQL] Merging rows into one result?

2006-03-11 Thread Christopher Browne
Centuries ago, Nostradamus foresaw when [EMAIL PROTECTED] ("Jesper K. Pedersen") would write: > Is it possible to use SQL to merge data into one result? > > A theorethical example to explain: > > tbl_test ( > id integer, > information varchar(25)) > > id | information > ---+-- > 1

[SQL] pgsql aggregate: conditional max

2006-03-11 Thread Weimao Ke
Hi, I need a special aggregation function. For instance, given the following table data: aid| cat | weight --+-+- a1 | Drama | 1 a1 | Romance | 6 a1 | Short | 1 a1 | Other | 7 a2 | Comedy | 1 a2 | Drama | 2 a3

Re: [SQL] pgsql aggregate: conditional max

2006-03-11 Thread Jeffrey Melloy
Weimao Ke wrote: Hi, I need a special aggregation function. For instance, given the following table data: aid| cat | weight --+-+- a1 | Drama | 1 a1 | Romance | 6 a1 | Short | 1 a1 | Other | 7 a2 | Comedy | 1 a2 | Dram

Re: [SQL] pgsql aggregate: conditional max

2006-03-11 Thread Michael Fuhr
On Sun, Mar 12, 2006 at 12:09:48AM -0500, Weimao Ke wrote: > I want to group by "aid" and choose the category (i.e., "cat") with the > largest "weight": > > aid | max_weighted_cat > +- > a1 | Other > a2 | Drama > a3 | Adult PostgreSQL has a non-standard DI

Re: [SQL] pgsql aggregate: conditional max

2006-03-11 Thread Michael Fuhr
On Sun, Mar 12, 2006 at 12:34:57AM -0500, Jeffrey Melloy wrote: > Should be able to do this with a standard max() aggregate. > > select aid, cat, max(weight) > from table > group by aid, cat; That query returns the maximum weight for each (aid, cat) pair. Against the example data it returns the e