Saturday, 15 June 2013

aggregate functions - count records in MYSQL table before certain spot -



aggregate functions - count records in MYSQL table before certain spot -

i have simple 2 column table in mysql: col1=sex , col2=name

i want find out how many records (count) exist prior particular record. in pseudo-mysql:

select count(*) before sex="m" , name="bob" sort name

assuming there 1 bob, , lots of male , female records.

how can count how many records meet criteria prior chosen record?

try this,

select count(*) table rownum < (select rownum table sex='m' , name='bob' limit 1);

mysql aggregate-functions

No comments:

Post a Comment