views:

32

answers:

1

regarding to this question, i have a problem if use that query for count some data. How to make it can count data for ex. from 2010-01 until 2010-05?

after use that query the show as null. this is my query:

SELECT id, Line, COUNT( Serial_number ) AS Qty,
       SUM(S), SUM(A), SUM(B), SUM(C),
       (SUM( S ) + SUM( A ) + SUM( B ) * 0.4 + SUM( C ) * 0.1) / COUNT( Serial_number ) AS QP
FROM `inspection_report`
+3  A: 
SELECT id, Line, COUNT( Serial_number ) AS Qty,
       SUM(S), SUM(A), SUM(B), SUM(C),
       (SUM( S ) + SUM( A ) + SUM( B ) * 0.4 + SUM( C ) * 0.1) / COUNT( Serial_number ) AS QP
FROM `inspection_report`
WHERE `thedate` BETWEEN '2010-01-01' AND '2010-06-00'
ITroubs
owh..now i found my fault. i'm just type '2010-01' AND '2010-06' that make me get result as null.thanks for your advise.
klox
also notice the '00' in BETWEEN '2010-01-01' AND '2010-06-00' because this will give you all results where thedate is bigger or equal than 2010-01-01 and smaller or equal 2010-05-(lastDayOfTheMonth)
ITroubs