Re: [SQL] JOIN

2007-06-05 Thread Loredana Curugiu
Any help, please? On 6/5/07, Loredana Curugiu <[EMAIL PROTECTED]> wrote: Hi everybody, I have the following table: count | theme | receiver| date | dates | ---+---+---

Re: [SQL] JOIN

2007-06-05 Thread Richard Huxton
Loredana Curugiu wrote: Any help, please? So I have the following query: SELECT SUM(A.count), A.theme, A.receiver, A.dates FROM my_table A INNER JOIN my_table B ON A.theme=B.theme AND A

Re: [SQL] JOIN

2007-06-05 Thread Loredana Curugiu
So I have the following query:>> >>SELECT SUM(A.count), >> A.theme, >> A.receiver, >> A.dates >> FROM my_table A >> INNER JOIN my_table B >> ON A.theme=B.theme >> AND A.receiver=B.receive

Re: [SQL] JOIN

2007-06-05 Thread Richard Huxton
Loredana Curugiu wrote: So I have the following query:>> >>SELECT SUM(A.count), >> A.theme, >> A.receiver, >> A.dates >> FROM my_table A >> INNER JOIN my_table B >> ON A.theme=B.theme >>

Re: [SQL] JOIN

2007-06-05 Thread Gregory Stark
"Loredana Curugiu" <[EMAIL PROTECTED]> writes: > I am trying to say that sum column it is not calculated correctly. It looks like your counts are high. That would imply that your join clauses are matching more than one combination of rows. Ie, it's counting some rows multiple times because there

[SQL] JOIN

2007-06-05 Thread Loredana Curugiu
Hi everybody, I have the following table: count | theme | receiver| date | dates | ---+---+--++

Re: [SQL] JOIN

2007-06-05 Thread Oliveiros Cristina
Hey, Loredana. Please advice me, you need to sum for a certain pair (Theme, receiver) the number that appears on count for every record whose date is in dates column, is this correct? But in what record's dates column? On all of them? Or just the dates column of the records that have that (Theme

Re: [SQL] JOIN

2007-06-05 Thread Loredana Curugiu
You don't actually say what's wrong. What are you expecting as output? I should obtain the following result: sum | theme | receiver | dates +--+--+ 8 | CRIS | +4074

[SQL] CREATE RULE with WHERE clause

2007-06-05 Thread Ranieri Mazili
Hello, I need to create a rule, but I need that it have a WHERE clause, how bellow: CREATE RULE rule_role_sul AS ON SELECT TO t1 WHERE roles = 'role_sul' DO INSTEAD SELECT field1, field2 FROM t2; CREATE RULE rule_role_sul AS ON SELECT TO t1 WHERE roles = 'role_norte' DO IN

Re: [SQL] JOIN

2007-06-05 Thread Richard Huxton
Loredana Curugiu wrote: You don't actually say what's wrong. What are you expecting as output? I should obtain the following result: [snip] Well, I've attached a test script using your example data and a copy of my results. Nothing leaping out as wrong here. It's entirely possible I've not

Re: [SQL] [NOVICE] JOIN

2007-06-05 Thread Sean Davis
Loredana Curugiu wrote: > Hi everybody, > > I have the following table: > > count | theme | receiver| date > | dates >| > ---+---+--

Re: [SQL] [GENERAL] CREATE RULE with WHERE clause

2007-06-05 Thread Richard Broersma Jr
> CREATE RULE rule_role_sul AS > ON SELECT TO t1 WHERE roles = 'role_sul' > DO INSTEAD > SELECT field1, field2 FROM t2; > > CREATE RULE rule_role_sul AS > ON SELECT TO t1 WHERE roles = 'role_norte' > DO INSTEAD > SELECT field3, field4 FROM t2; From: http://www.po

Re: [SQL] JOIN

2007-06-05 Thread Loredana Curugiu
On 6/5/07, Oliveiros Cristina <[EMAIL PROTECTED]> wrote: Hey, Loredana. Hi Oliveiros! Nice to "see" you again! Please advice me, you need to sum for a certain pair (Theme, receiver) the number that appears on count for every record whose date is in dates column, is this correct? Yap. Bu

Re: [SQL] JOIN

2007-06-05 Thread Loredana Curugiu
On 6/5/07, Loredana Curugiu <[EMAIL PROTECTED]> wrote: On 6/5/07, Oliveiros Cristina <[EMAIL PROTECTED]> wrote: > > Hey, Loredana. Hi Oliveiros! Nice to "see" you again! Please advice me, > you need to sum for a certain pair (Theme, receiver) the number that > appears on count for every rec

Re: [SQL] JOIN

2007-06-05 Thread Oliveiros Cristina
Hey, Loredana. Nice to "see" you too ;-) Thank you for your detailed clarifications. Hmm...try to add the following clause to your INNER JOIN AND A.date = B.Date Like this : INNER JOIN view_sent_messages B ON A.theme=B.theme AND A.receiver=B.receiver AND A.d

Re: [SQL] [GENERAL] CREATE RULE with WHERE clause

2007-06-05 Thread Michael Glaesemann
On Jun 5, 2007, at 8:11 , Ranieri Mazili wrote: CREATE RULE rule_role_sul AS ON SELECT TO t1 WHERE roles = 'role_sul' DO INSTEADSELECT field1, field2 FROM t2; CREATE RULE rule_role_sul AS ON SELECT TO t1 WHERE roles = 'role_norte' DO INSTEADSELECT field3, field4 FRO

Re: [SQL] JOIN

2007-06-05 Thread Loredana Curugiu
Hmm...try to add the following clause to your INNER JOIN AND A.date = B.Date Like this : INNER JOIN view_sent_messages B ON A.theme=B.theme AND A.receiver=B.receiver AND A.date = b.Date AND B.date=ANY (A.dates) Doesn't work. I get the result

Re: [SQL] JOIN

2007-06-05 Thread Oliveiros Cristina
Hello again, Loredana. Additional information required :-) imagine the following situation 1| LIA | recv1 | date1 | (date1,date2) 2|LIA | recv1 |date 1 | (date2,date3) 3| LIA | recv1 | date1 | (date1,date3) Should this yield 6? Or 4? date 1 is not on the second dates column, but it is on the

Re: [SQL] JOIN

2007-06-05 Thread Loredana Curugiu
On 6/5/07, Oliveiros Cristina <[EMAIL PROTECTED]> wrote: Hello again, Loredana. Additional information required :-) imagine the following situation 1| LIA | recv1 | date1 | (date1,date2) 2|LIA | recv1 |date 1 | (date2,date3) 3| LIA | recv1 | date1 | (date1,date3) Should this yield 6? Or 4

Re: [SQL] JOIN

2007-06-05 Thread Oliveiros Cristina
And , still, in your query, you are grouping by A.dates... is there any reason for this that I am missing ? SELECT SUM(A.count), A.theme, A.receiver, A.dates FROM my_table A INNER JOIN my_table B ON A

Re: [SQL] current_date / datetime stuff

2007-06-05 Thread Gerardo Herzig
We should have a onliner contest. I love oneliners!!! oneliner: select date_trunc('month',now()) + ((8 - extract('dow' from date_trunc ('month',now()))||'days')::text)::interval; Kristo On 04.06.2007, at 19:39, Michael Glaesemann wrote: ---(end of broadcast)--

Re: [SQL] current_date / datetime stuff

2007-06-05 Thread Rodrigo De León
On 6/5/07, Gerardo Herzig <[EMAIL PROTECTED]> wrote: We should have a onliner contest. I love oneliners!!! +1 on that ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] [GENERAL] Encrypted column

2007-06-05 Thread Joe Conway
Marko Kreen wrote: On 6/5/07, Brian Mathis <[EMAIL PROTECTED]> wrote: pgcrypto also supports md5, so I'm not sure what you're referring to here. digest(psw, 'md5') vs. crypt(psw, gen_salt('md5')) As I already mentioned, *salting* before you hash is a very important step. I'm not sure if you

[SQL] How to find missing values across multiple OUTER JOINs

2007-06-05 Thread Drew
I'm having troubles using multiple OUTER JOINs, which I think I want to use to solve my problem. My problem is to find all non-translated string values in our translations database, given the 4 following tables: SOURCE (source_id PRIMARY KEY, language_id, value, ...) TRANSLATION (translatio