sqlite, select second smallest in each group -



sqlite, select second smallest in each group -

i have sqlite database named heroes trying find sec oldest date each person has used service. find oldest date used:

select min(date), cust_num heroes grouping cust_num;

now, using next find sec oldest date:

select max(date), cust_num heroes date in (select date heroes order date limit 2) grouping cust_num;

however, giving me 9 people used service 2nd time on first day there data. advice?

thanks!

if instead bring together subquery on client number you'll sure dates match appropriate client number. sec effort didn't have certainty.

select h.cust_num, max(d.date) heroes h bring together ( select cust_num, date heroes order date limit 2 ) d on d.cust_num = h.cust_num grouping h.cust_num order h.cust_num;

sqlite

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -