Ryan
Ryan

Reputation: 989

MySQL to count rows in between two numbers

I want a query to count rows in between two numbers. I have a table called purchase_order and in that there is a column called age, And in that age column simple numeric data is populating like 30, 55, 90, 95, 100....So for example I want only count rows in between 90 to 100. So far I tried this

SELECT * FROM office_in_box.purchase_order WHERE age  BETWEEN 90 and 110

Also I want the count of all rows in between 90 to 110.

Thanks

Upvotes: 0

Views: 2876

Answers (2)

Nana Partykar
Nana Partykar

Reputation: 10548

The COUNT() function returns the number of rows that matches a specified criteria.

SELECT COUNT(*) FROM office_in_box.purchase_order 
WHERE age BETWEEN 90 and 110

Upvotes: 2

Blank
Blank

Reputation: 12378

Just use COUNT:

SELECT COUNT(*) FROM office_in_box.purchase_order WHERE age  BETWEEN 90 and 110

Upvotes: 4

Related Questions