[thelist] SQL query question about AND OR and date ranges

John Handelaar john at evolt.org.uk
Thu Sep 5 09:39:01 CDT 2002


% -----Original Message-----
% From: thelist-admin at lists.evolt.org
% [mailto:thelist-admin at lists.evolt.org]On Behalf Of Jay Blanchard
% Sent: 05 September 2002 15:30
% To: thelist at lists.evolt.org
% Subject: [thelist] SQL query question about AND OR and date ranges
%
%
% mysql> SELECT cdr.discn_dt, COUNT(cdr.ani) AS quantity,
% SUM(cdr.calldur/60)
% AS minutes
%     -> FROM tblCDR cdr LEFT OUTER JOIN tblCDRExempt e
%     -> ON cdr.ani = e.ExemptCDR
%     -> WHERE e.ExemptCDR IS NULL
%     -> AND cdr.discn_dt BETWEEN '2002-07-01' AND '2002-07-30'
%     -> AND

(

% cdr.dialedno LIKE '800%'
%     -> OR cdr.dialedno LIKE '866%'

)

%     -> GROUP BY cdr.discn_dt;

Put the brackets in.  If you think about it for a moment
you'll figure out why for yourself :-)

------------------------------------------
John Handelaar

T +44 20 8933 1494       M +44 7930 681789
F +44 870 169 7657   E john at userfrenzy.com
------------------------------------------



More information about the thelist mailing list