2

This is my table structure. I have to fetch the zip_code's range as per they created in database table in given between date.

enter image description here

For example in the given between dates are 4-aug-14 to 9-aug-14 i need follwing result

zip number

90620 10

90621 5

How i write mysql query for this.

3 Answers 3

2

IS this you want the result DEMO

try

SELECT zip
    , COUNT(1) AS count
FROM table1
WHERE created BETWEEN '2014-08-04 00:00:00' AND '2014-08-08 23:59:59'
GROUP BY zip
ORDER BY count DESC
Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

SELECT zip
    , COUNT(id) AS count
FROM [table]
WHERE created BETWEEN '2014-08-04 00:00:00' AND '2014-08-08 23:59:59'
GROUP BY zip
ORDER BY count DESC

Comments

1

try :

Select zip, count(*) from table_name where created between 'from_date' and 'to_date' group by zip

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.