[SQL] Using Query Result in WHERE Clause

2006-06-02 Thread operationsengineer1
hi all, SUMMARY: i want to replace AND t_inspect.inspect_pass = 'f' with a complex query that yields the same result. the complex query is in the form of... SELECT DISTINCT ON (t_inspect.inspect_id) t_inspect_result.inspect_result_pass, t_inspect_result.inspect_result_id FROM t_insp

Re: [SQL] Advanced Query

2006-06-02 Thread Michael Fuhr
On Fri, Jun 02, 2006 at 10:09:01AM -0700, [EMAIL PROTECTED] wrote: > Michael, my derivative of your query example works > great - thank you! > > i think i understand everything except why multiplying > by 1.0 is necessary. when i take it out, my expected > result, 0.500..., turns into 0 -

Re: [SQL] Am I crazy or is this SQL not possible

2006-06-02 Thread Aaron Bono
Only if you assume that ordering by unique_id and by date_sent are equivalent.  That may be the case but I personally hate making assumptions like that.  When someone goes into the database and updates records (clean up bad data, etc.) your perfectly running query can suddenly produce bad results.

Re: [SQL] Am I crazy or is this SQL not possible

2006-06-02 Thread Klay Martens
Sorry to stick my nose in here...would not this work better?SELECT broadcast_id,date_sent,status from broadcast_history whereunique_id in (SELECT max(unique_id) from broadcast_history group by broadcast_id);Seems like a simpler option.  - Original Message -- From:Patrick Jacquot Sent:Friday

Re: [SQL] Am I crazy or is this SQL not possible

2006-06-02 Thread Patrick Jacquot
Collin Peters wrote: I am having some serious mental block here. Here is the abstract version of my problem. I have a table like this: unique_id (PK) broadcast_id date_sent status 1 1 2005-04-0430 2 1