Please help me with building up following query: I have a joined table from a selection query:
select nevlista.nevID as ColA, nkhk.nevktghID as ColB, nkhk.ktghelyID as ColC from nevlista inner join nkhk on nevlista.nevID = nkhk.nevID where nevlista.nevID = nkhk.nevID This gives following result:
ColA ColB ColC 90002 629 6 90003 835 9 90003 875 12 90003 112 12 90004 424 17 90004 570 1 90004 905 17 90005 648 1 90005 649 17 90005 523 17 and so on... Now, I need from every group of same ID-s in ColA, the last but one highest value from ColB (and the value from ColC). (The number of same ID-s in ColA are different, usually there are 2 to 5 records with the same ID).