Re: How to write this query?

2005-11-10 Thread SGreen
Michael McFadden <[EMAIL PROTECTED]> wrote on 11/10/2005 08:55:13 AM: > Hi Jerry. > > I'm new to the list, so don't take this as the final > answer. Wait for a guru to pounce with a better > solution! > > But, here is my idea: > > Before we start, note that "order" is a reserved word. > So we

Re: How to write this query?

2005-11-10 Thread Jerry Swanson
item_status table can have more than one status. I need to get the latest status from the table. Thanks On 11/10/05, ISC Edwin Cruz <[EMAIL PROTECTED]> wrote: > > Try it: > > select distinct a.* > from order a, > item b, > item_status c, > status d > where a.order_id = b.order_id > and b.item_i

RE: How to write this query?

2005-11-10 Thread ISC Edwin Cruz
Try it: select distinct a.* from order a, item b, item_status c, status d where a.order_id = b.order_id and b.item_id=c.item_id and c.item_status_id = d.item_status_id where d.status = 'completed' It isnĀ“t "tunned" but I think that it works for that you want -Mensaje original- De: Jerry

Re: How to write this query?

2005-11-10 Thread Michael McFadden
Hi Jerry. I'm new to the list, so don't take this as the final answer. Wait for a guru to pounce with a better solution! But, here is my idea: Before we start, note that "order" is a reserved word. So we must backtick `order` to reference the table in SQL (or the interpreter will think we're u

RE: how to write this query?

2005-02-21 Thread Gordon
0/2000 | 2 | 01/10/2000 | +--++---+---+--- -+---++ 10 rows in set (0.00 sec) -Original Message- From: Mike Rains [mailto:[EMAIL PROTECTED] Sent: Monday, February 21, 2005 9:33 AM To: mysql@lists.mysql.com Subject: Re: how to write this query? SELECT start_date, end_date, DATEDIFF(end_date,

Re: how to write this query?

2005-02-21 Thread Mike Rains
SELECT start_date, end_date, DATEDIFF(end_date, start_date) - (WEEK(end_date) - WEEK(start_date)) * 2 AS business_days FROM DateDiffs ORDER BY start_date; +-+-+---+ | start_date | end_date| business

Re: how to write this query?

2005-02-21 Thread Jerry Swanson
It's not precisely correct. When time difference is less than 7, the time is calcualted wrong end_time 2005-01-10 17:53:33 end_time 2005-01-04 16:44:57 Result: days 6 Result: bussiness_days 6 On Sat, 19 Feb 2005 09:50:06 -0500, Mike Rains <[EMAIL PROTECTED]> wrote: > On Sat, 19 Feb 2005

Re: how to write this query?

2005-02-19 Thread Mike Rains
On Sat, 19 Feb 2005 14:01:05 +, Jerry Swanson <[EMAIL PROTECTED]> wrote: > I have two dates (start_date, end_date). Datediff() function returns > difference in days. > I need the difference but not including Satuday and Sunday. > > Any ideas? C:\Program Files\MySQL\MySQL Server 4.1\bin>mysql

Re: How to write this query

2003-10-03 Thread Bill Easton
s for B.*. Then, the second left join gives you C.* for that A_ID; it doesn't matter that the B.* part contains nulls. Bill > From: sean peters <[EMAIL PROTECTED]> > To: "Kevin Fries" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> > Subject: Re: How to write th

RE: How to write this query

2003-10-01 Thread Kevin Fries
ssage- > From: sean peters [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 01, 2003 2:23 PM > To: Kevin Fries; [EMAIL PROTECTED] > Subject: Re: How to write this query > > > Unfortunately that wont always work either. > > For instance, assume that there is an

Re: How to write this query

2003-10-01 Thread sean peters
Unfortunately that wont always work either. For instance, assume that there is an A record with A_ID = 4 And that there is a C record where A_ID = 4, but NO B record where A_ID = 4 So, executing the query: > SELECT A_data, B_data, C_data > FROM A LEFT JOIN B ON A.A_ID = B.B_ID LEFT JOIN C ON A.A_

RE: How to write this query

2003-10-01 Thread Kevin Fries
You're on the right track with LEFT JOIN. Just continue the thought... Try: SELECT A_data, B_data, C_data FROM A LEFT JOIN B ON A.A_ID = B.B_ID LEFT JOIN C ON A.A_ID = C.C_ID WHERE A.A_ID = 4; > -Original Message- > From: sean peters [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October

Re: How to write this query pls?

2003-05-27 Thread Peter Brawley
>Ways around inner select statments >Select ID, Sum(CASE WHEN phone.PHN = NULL THEN 1 ELSE 0 END) as PHNCount >from person left outer join phone on ID >where PHNCount = 0 GROUP BY phone.ID; The alias in the WHERE clause is illegal; it would have to be SELECT persons.ID, Sum( CASE WHE

Re: How to write this query??

2003-01-24 Thread Bill Easton
If you have the option to change the table structure, just replace the date and time columns with a timestamp column. If you must keep the current structure then the following wil work, but it will not use indexes in the search: select ... where concat(today,' ',heure1) be