SQLyog
 sql >> Database >  >> Database Tools >> SQLyog

Seleziona il SECONDO ULTIMO record in ogni gruppo

Ecco uno pseudo-codice sql per iniziare:

select
  penultimate.*
from data as penultimate
left join (
  /* query on data to return last row frome each group */
) as ultimate
  on /* sql to join 2nd last record on each group to last group */
where not ultimate.SerialNo is null