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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

math function

Status
Not open for further replies.

Bao

Programmer
Jul 20, 2001
3
US
is there a function that can divide a range of numeric data into sub-categories? for example, if I have data from 1 to 20, and I want result to be group by (1,5), (6,10), (11,15), and (16,20) intervals.

Thank you.
 
Boa, if the groups are regular groups of 5 you could try grouping by something like [tt]trunc(x/5)[/tt] i.e. the integer result of a division operation (n.b. syntax may vary depending on RDBMS); if not you may want a look up table with lower and upper range bounds and an identifier, join to it where value is between the bounds and group on the identifier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top