Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with limit and sum

Status
Not open for further replies.

pushyr

Programmer
Jul 2, 2007
159
GB
i can select records 1- 10 using...
GROUP BY x
ORDER BY x DESC
LIMIT 10

and i can select a specifc range of records...
GROUP BY x
ORDER BY x DESC
LIMIT 10,15

but what i can't figure out are two things....

1) selecting records from 10 to the last row
i can do it by saying LIMIT 10,10000000
but is there a proper way to do this?

2) i can't figure out how to sum the records from
10 to the last row
i tried this but get no results...

SELECT
date AS MONTH,
SUM(category) As TotalCategory
FROM table
WHERE clause1 = '1'
AND date = 'feb'
GROUP BY date
ORDER BY Category DESC
LIMIT 10,1000000
 
Make it a subselect.

SELECT date, sum(category) from (
SELECT
date,category
FROM table
WHERE clause1 = '1'
AND date = 'feb'
LIMIT 10,1000000
) as x
GROUP BY date
ORDER BY date DESC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top