From: Martin Gainty Date: November 3 2009 9:09pm Subject: RE: Customers with no recent orders? List-Archive: http://lists.mysql.com/mysql/219225 Message-Id: Content-Type: multipart/alternative; boundary="_4a77869a-826a-45fe-8ede-25e759d4aa96_" --_4a77869a-826a-45fe-8ede-25e759d4aa96_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable any column used in any group functions such as SUM needs to be requested in= select column e.g. select foo from table where sum(foo)=3D1.00 Martin Gainty=20 ______________________________________________=20 Verzicht und Vertraulichkeitanmerkung/Note de d=E9ni et de confidentialit= =E9 =20 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaeng= er sein=2C so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiter= leitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient l= ediglich dem Austausch von Informationen und entfaltet keine rechtliche Bin= dungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen w= ir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut =EAtre privil=E9gi=E9. Si vous n'=EAtes= pas le destinataire pr=E9vu=2C nous te demandons avec bont=E9 que pour sat= isfaire informez l'exp=E9diteur. N'importe quelle diffusion non autoris=E9e= ou la copie de ceci est interdite. Ce message sert =E0 l'information seule= ment et n'aura pas n'importe quel effet l=E9galement obligatoire. =C9tant d= onn=E9 que les email peuvent facilement =EAtre sujets =E0 la manipulation= =2C nous ne pouvons accepter aucune responsabilit=E9 pour le contenu fourni= . > Subject: Re: Customers with no recent orders? > From: brian@stripped > Date: Tue=2C 3 Nov 2009 12:54:31 -0800 > To: mysql@stripped >=20 > More info. If the tables look like this: >=20 > customers > ------------------ > cust_id > signup_date >=20 > orders > ------------------ > order_id > cust_id > order_date >=20 > Then the SQL needs to accomplish something like this: >=20 > select * from customers > left join orders on customers.cust_id =3D orders.cust_id > where signup_date < now() - interval 14 day > and sum(if(order_date > now() - interval 14 day=2C 1=2C 0)) =3D 0 >=20 > But that gives me "Invalid use of group function". >=20 > --=20 > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dmgainty@stripped= om >=20 =20 _________________________________________________________________ Find the right PC with Windows 7 and Windows Live.=20 http://www.microsoft.com/Windows/pc-scout/laptop-set-criteria.aspx?cbid=3Dw= l&filt=3D200=2C2400=2C10=2C19=2C1=2C3=2C1=2C7=2C50=2C650=2C2=2C12=2C0=2C100= 0&cat=3D1=2C2=2C3=2C4=2C5=2C6&brands=3D5=2C6=2C7=2C8=2C9=2C10=2C11=2C12=2C1= 3=2C14=2C15=2C16&addf=3D4=2C5=2C9&ocid=3DPID24727::T:WLMTAGL:ON:WL:en-US:WW= L_WIN_evergreen2:112009= --_4a77869a-826a-45fe-8ede-25e759d4aa96_--