[SQL] Sql Query help: Remove Sub Selects

2005-07-13 Thread Rob
Hi Gang, I'm trying to optimize a query: This query below returns something like this: event_id | eu_tid | event_name | event_when | day | mon | start | end|event_users | contact_phone| contact_pager | num_opps --++-

Re: [SQL] SQL query help?

2005-03-07 Thread Michael Fuhr
On Mon, Mar 07, 2005 at 04:22:15PM -, John McGough wrote: > +---+---++-+--+ > | ID | JobID | UserID | Finished | Comment | > +---+---++-+--+ This table output doesn't look like PostgreSQL's usual format. > but I keep getting MySQL err

Re: [SQL] SQL query help?

2005-03-07 Thread Keith Worthington
John McGough wrote: SELECT Count(*) FROM Work WHERE (UserID='user1' AND MAX(Finished)=0) Work:- +---+---++-+--+ | ID | JobID | UserID | Finished | Comment | +---+---++-+--+ | 1 | 1| user1 | 0 | ...| | 2

[SQL] SQL query help?

2005-03-07 Thread John McGough
SELECT Count(*) FROM Work WHERE (UserID='user1' AND MAX(Finished)=0) Work:- +---+---++-+--+ | ID | JobID | UserID | Finished | Comment | +---+---++-+--+ | 1 | 1| user1 | 0 | ...| | 2 | 1|

Re: [SQL] Query Help using Except

2003-10-26 Thread Bruno Wolff III
On Thu, Oct 23, 2003 at 14:17:08 -0400, [EMAIL PROTECTED] wrote: > > I can't do the following, since the number of selected columns have to match: One option is to use where NOT EXISTS instead of EXCEPT. Another way would be to add A.id to the rows in the set difference using a join. I expect

Re: [SQL] Query Help

2003-10-23 Thread yusuf0478
Wouldn't that return every A.id ? since A.id would be compared to -1, and the wouldnt' be the same. I want: select min(A.id) such that A.charge, B.userid, C.employee_id in ( select A.charge , B.user_id , C.employee_id from A inner join B using (user_id) inner join C using (employe

[SQL] Query Help using Except

2003-10-23 Thread yusuf0478
I'm interested in finding the minimim A.id such that the following holds: select A.charge , B.user_id , C.employee_id from A inner join B using (user_id) inner join C using (employee_id) except select X.charge , Y.user_id , Z.employee_id from X inner join Y using (user_id) inner

Re: [SQL] Query Help

2003-10-23 Thread scott.marlowe
On Thu, 23 Oct 2003 [EMAIL PROTECTED] wrote: > I'm interested in finding the minimim A.id such that the following holds: > > select A.charge > , B.user_id > , C.employee_id > from A > inner join B using (user_id) > inner join C using (employee_id) > > except > > select X.charge > ,

[SQL] Query Help

2003-10-23 Thread yusuf0478
I'm interested in finding the minimim A.id such that the following holds: select A.charge , B.user_id , C.employee_id from A inner join B using (user_id) inner join C using (employee_id) except select X.charge , Y.user_id , Z.employee_id from X inner join Y using (user_id) inner

Re: [SQL] SQL query help!

2002-11-28 Thread Arcadius A.
Hello! "Luis Sousa" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > This is a cryptographically signed message in MIME format. > > --ms080209060900030807050408 > Content-Type: text/plain; charset=us-ascii; format=flowed > Content-Transfer-Encoding: 7

Re: [SQL] SQL query help!

2002-11-27 Thread Luis Sousa
Tell me what did you try with limit and group by. Where's IN, why don't you use EXISTS instead. It runs much master ! Regards, Luis Sousa Arcadius A. wrote: Hello! I hope that someone here could help. I'm using PostgreSQL7.1.3 I have 3 tables in my DB: the tables are defined in the following

[SQL] SQL query help!

2002-11-26 Thread Arcadius A.
Hello! I hope that someone here could help. I'm using PostgreSQL7.1.3 I have 3 tables in my DB: the tables are defined in the following way: CREATE TABLE category( id SERIAL NOT NULL PRIMARY KEY, // etc etc ) ; CREATE TABLE subcategory( id SERIAL NOT NULL PRIMARY KEY, categoryid int CONSTRAI

Re: [SQL] Query Help

2000-12-28 Thread Brian C. Doyle
Thank you to everyone with their suggestions. Where on the PostgreSQL site would I have found more info on the NOT EXISTS At 11:20 AM 12/27/00 -0500, you wrote: >What do I have to do a query where information in table1 is not in table2 > >I am looking for something like > >Select table1.firs

Re: [SQL] Query Help

2000-12-28 Thread patrick . jacquot
"Brian C. Doyle" wrote: > What do I have to do a query where information in table1 is not in table2 > > I am looking for something like > > Select table1.firstname where table1.firstname is not in table2.firstname > and table2.date='yesterday' > > I tried > Select table1.firstname where table1.fi

Re: [SQL] Query Help

2000-12-27 Thread Yury Don
Hello Brian, Wednesday, December 27, 2000, 9:20:53 PM, you wrote: BCD> What do I have to do a query where information in table1 is not in table2 BCD> I am looking for something like BCD> Select table1.firstname where table1.firstname is not in table2.firstname BCD> and table2.date='yesterday'

RE: [SQL] Query Help

2000-12-27 Thread Francis Solomon
Hi Brian, Try something like this: SELECT firstname FROM table1 WHERE firstname NOT IN (SELECT firstname FROM table2 WHERE table2.date='yesterday'::date); Hope this helps. Francis Solomon > > What do I have to do a query where information in table1 is > not in table2 > > I am looking for some

[SQL] Query Help

2000-12-27 Thread Brian C. Doyle
What do I have to do a query where information in table1 is not in table2 I am looking for something like Select table1.firstname where table1.firstname is not in table2.firstname and table2.date='yesterday' I tried Select table1.firstname where table1.firstname != table2.firstname and table2