[GENERAL] SELECT question (splitting a field)

2007-09-04 Thread Madison Kelly
Hi all, Hopefully a quick question... Why does: nmc= SELECT 'Y' AS local FROM domains WHERE dom_name='test.com'; local --- Y (1 row) Work but: nmc= SELECT 'Y' AS local FROM domains WHERE '@'||dom_name IN ('[EMAIL PROTECTED]'); local --- (0 rows) Not work? I am sure I

Re: [GENERAL] SELECT question (splitting a field)

2007-09-04 Thread Rodrigo De León
On 9/4/07, Madison Kelly [EMAIL PROTECTED] wrote: I am sure I am missing something simple. :) Yeah... '[EMAIL PROTECTED]' '@test.com' ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [GENERAL] SELECT question (splitting a field)

2007-09-04 Thread Scott Marlowe
On 9/4/07, Madison Kelly [EMAIL PROTECTED] wrote: Hi all, Hopefully a quick question... Why does: nmc= SELECT 'Y' AS local FROM domains WHERE dom_name='test.com'; local --- Y (1 row) Work but: nmc= SELECT 'Y' AS local FROM domains WHERE '@'||dom_name IN ('[EMAIL

Re: [GENERAL] SELECT question (splitting a field)

2007-09-04 Thread Richard Huxton
Madison Kelly wrote: nmc= SELECT 'Y' AS local FROM domains WHERE '@'||dom_name IN ('[EMAIL PROTECTED]'); local --- (0 rows) Not work? I don't think IN does what you think it does. It's not a substring-test, but a set test: SELECT 1 WHERE 'x' IN ('a','b','c','x'); SELECT a FROM foo

Re: [GENERAL] SELECT question (splitting a field)

2007-09-04 Thread Madison Kelly
Rodrigo De León wrote: On 9/4/07, Madison Kelly [EMAIL PROTECTED] wrote: I am sure I am missing something simple. :) Yeah... '[EMAIL PROTECTED]' '@test.com' Well now, don't I feel silly. *sigh* Thanks! Madi ---(end of broadcast)--- TIP

Re: [GENERAL] SELECT question (splitting a field)

2007-09-04 Thread Madison Kelly
Richard Huxton wrote: Madison Kelly wrote: nmc= SELECT 'Y' AS local FROM domains WHERE '@'||dom_name IN ('[EMAIL PROTECTED]'); local --- (0 rows) Not work? I don't think IN does what you think it does. It's not a substring-test, but a set test: SELECT 1 WHERE 'x' IN

Re: [GENERAL] SELECT question (splitting a field)

2007-09-04 Thread Richard Huxton
Madison Kelly wrote: SELECT 'Y' AS local FROM domains d, users u WHERE u.usr_dom_id=d.dom_id AND u.usr_email||'@'||d.dom_name IN ('[EMAIL PROTECTED]'); Though this may not be the most efficient. In my case, the 'usr_email' is the LHS of the '@' sign and 'dom_name' is the domain name. If I

Re: [GENERAL] Select question

2007-08-31 Thread Madison Kelly
Merlin Moncure wrote: I seem to recall giving out a query about that in the IRC channel a while back...so if you got it from me, now I'll attempt to finish the job :-). If you can get postfix to look at a view, maybe you could CREATE VIEW email_v AS SELECT usr_email, dom_name,

[GENERAL] Select question

2007-08-30 Thread Madison Kelly
Hi all, I am pretty sure I've done this before, but I am drawing a blank on how I did it or even what commands I need. Missing the later makes it hard to search. :P I've got Postfix working using PostgreSQL as the backend on a small, simple test database where I have a simple table

Re: [GENERAL] Select question

2007-08-30 Thread Madison Kelly
Woops, I wasn't careful enough when I wrote that email, sorry. The results showed my real domains instead of 'test.com'. I had different domains in the test and real DBs. Madison Kelly wrote: email_file - feneon.com/mkelly/inbox and email_file

Solved! Was: Re: [GENERAL] Select question

2007-08-30 Thread Madison Kelly
Madison Kelly wrote: Hi all, I am pretty sure I've done this before, but I am drawing a blank on how I did it or even what commands I need. Missing the later makes it hard to search. :P I've got Postfix working using PostgreSQL as the backend on a small, simple test database where I

Re: [GENERAL] Select question

2007-08-30 Thread Merlin Moncure
On 8/30/07, Madison Kelly [EMAIL PROTECTED] wrote: Hi all, I am pretty sure I've done this before, but I am drawing a blank on how I did it or even what commands I need. Missing the later makes it hard to search. :P I've got Postfix working using PostgreSQL as the backend on a small,

Re: [GENERAL] SELECT question

2007-08-21 Thread Michelle Konzack
Am 2007-08-17 12:53:41, schrieb Michael Glaesemann: On Aug 17, 2007, at 7:27 , Michelle Konzack wrote: * * Do not Cc: me, because I am on THIS list, if I write here.* You might want to consider changing your

Re: [GENERAL] SELECT question

2007-08-21 Thread Scott Marlowe
On 8/18/07, Michelle Konzack [EMAIL PROTECTED] wrote: Am 2007-08-17 12:53:41, schrieb Michael Glaesemann: (Is is just me or have there been a lot of queries that can be solved using DISTINCT ON recently?) I do not know... Since when does DISTINCT ON exist? I have been lurking on this

Re: [GENERAL] SELECT question

2007-08-21 Thread Alvaro Herrera
Michelle Konzack wrote: Am 2007-08-17 12:53:41, schrieb Michael Glaesemann: On Aug 17, 2007, at 7:27 , Michelle Konzack wrote: * * Do not Cc: me, because I am on THIS list, if I write here.* You might

[GENERAL] SELECT question

2007-08-17 Thread Michelle Konzack
* * Do not Cc: me, because I am on THIS list, if I write here.* * Keine Cc: an mich, bin auf DIESER Liste wenn ich hier schreibe. * * Ne me mettez pas en Cc:, je suis sur CETTE liste, si j'ecris ici. *

Re: [GENERAL] SELECT question

2007-08-17 Thread Michael Glaesemann
On Aug 17, 2007, at 7:27 , Michelle Konzack wrote: * * Do not Cc: me, because I am on THIS list, if I write here.* You might want to consider changing your mailing list subscription settings to eliminatecc, e.g.,

Re: [GENERAL] Select question..... is there a way to do this?

2007-08-04 Thread Rodrigo De León
On Aug 3, 11:17 pm, [EMAIL PROTECTED] (Karl Denninger) wrote: Ideas? SELECT item.user, item.subject, item.number FROM item, seen WHERE item.user = seen.user AND item.number = seen.number AND item.changed seen.lastviewed UNION SELECT item.user, item.subject, item.number FROM item,

[GENERAL] Select question..... is there a way to do this?

2007-08-03 Thread Karl Denninger
Assume the following tables: Table ITEM (user text, subject text, number integer, changed timestamp); table SEEN (user text, number integer, lastviewed timestamp); Ok, now the data in the SEEN table will have one tuple for each user and number in the table ITEM which a user has viewed, and the

[GENERAL] SELECT Question

2006-03-03 Thread Alex
Hi, i want to calculate the price difference, change% of 2 price records. Is there an easy way to do that within one query, rather than writing a function? Example: company, price_date, price, change, change_perc compA, 20060203,100,,, compA, 20060202,100,,, compA, 20060201,100,,, for one,

Re: [GENERAL] SELECT Question

2006-03-03 Thread Bruno Wolff III
On Sat, Mar 04, 2006 at 03:35:02 +1100, Alex [EMAIL PROTECTED] wrote: Hi, i want to calculate the price difference, change% of 2 price records. Is there an easy way to do that within one query, rather than writing a function? You can use a self join to do this. It won't be spectaculatly

Re: [GENERAL] SELECT Question

2003-11-21 Thread Alex
All, thanks for the many suggestions Alex Manfred Koizar wrote: On Thu, 20 Nov 2003 16:52:37 +0900, Alex [EMAIL PROTECTED] wrote: Is there an easy way to write a select statement that returns me the frist free number or any within the range of 200? For example if 1-30, and 32-50 are occupied

Re: [GENERAL] SELECT Question

2003-11-20 Thread Kris Jurka
On Thu, 20 Nov 2003, Alex wrote: Is there an easy way to write a select statement that returns me the frist free number or any within the range of 200? For example if 1-30, and 32-50 are occupied then i would like to fill in the new entry with id 31. If you had a table with an id column and

Re: [GENERAL] SELECT Question

2003-11-20 Thread Manfred Koizar
On Thu, 20 Nov 2003 16:52:37 +0900, Alex [EMAIL PROTECTED] wrote: Is there an easy way to write a select statement that returns me the frist free number or any within the range of 200? For example if 1-30, and 32-50 are occupied then i would like to fill in the new entry with id 31. Fortunately

Re: [GENERAL] SELECT Question

2003-11-20 Thread Joe Conway
Kris Jurka wrote: A useful generic function would be one something like range(min,max) that would return a set of rows so you wouldn't have to actually have a table. You mean like this? CREATE OR REPLACE FUNCTION test(int,int) RETURNS SETOF int AS ' BEGIN FOR i IN $1..$2 LOOP RETURN NEXT i;

Re: [GENERAL] SELECT question

2003-11-04 Thread Richard Huxton
On Tuesday 04 November 2003 10:54, Alex wrote: Hi, I have a bit string , 7 bits, every bit representing a day of the week. e.g. 1110011. Is there and easy way where I can translate/format that string in a query. I want to give the string back with a '-' for every 0 and the first char of the

[GENERAL] SELECT question

2003-11-04 Thread Alex
Hi, I have a bit string , 7 bits, every bit representing a day of the week. e.g. 1110011. Is there and easy way where I can translate/format that string in a query. I want to give the string back with a '-' for every 0 and the first char of the Day for every '1'. example 1100111 = SM--TFS.

Re: [GENERAL] SELECT Question

2003-09-01 Thread Alex
Jeffrey, second solution is a beauty... thanks a lot. Alex Jeffrey Melloy wrote: If I'm understanding you correctly, you can do something like: select cola, colb, exists (select 'x' from tableb where colc = colb) from

Re: [GENERAL] SELECT Question

2003-08-31 Thread Stephan Szabo
On Mon, 1 Sep 2003, Alex wrote: Hi, I need to form a query where i can add some columns based on the result. Table A ColA, ColB -- 1 A 2 B 3 A Table B ColC A If A exists if would like the result back as 1 A OK 2 B NG 3 A OK Is it

Re: [GENERAL] SELECT Question

2003-08-31 Thread Jeffrey Melloy
If I'm understanding you correctly, you can do something like: select cola, colb, exists (select 'x' from tableb where colc = colb) from tablea Since that has a subselect, you may get better performance with something

Re: [GENERAL] select question

2000-07-29 Thread Robert B. Easter
On Sat, 29 Jul 2000, [EMAIL PROTECTED] wrote: Dear all, Is there a way I can select the top 50 rows from table, 51 - 100 rows from table etc (with order clause)? It is because I am writing a message board and I would like to create the prev/next button on different page. Many

Re: [GENERAL] select question

2000-07-29 Thread Ian Turner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Is there a way I can select the top 50 rows from table, 51 - 100 rows from table etc (with order clause)? It is because I am writing a message board and I would like to create the prev/next button on different page. Look at the