Topic: sql query for selected only

Hi all,

Anyone has idea how to make sql query on selected values in tablegrid.
I have one button for ALL items with criteria of name
But I want to make one more button to execute only on selected in tbgrid

Here is example of all in tbgrid:

INSERT into table1 (name, lastname, s50, s52, s54, s56, s58, s60, idOrder)
select
name as name,
l_name as lastname,   
sum(s50) as s50,
sum(s52) as s52,
sum(s54) as s54,
sum(s56) as s56,
sum(s58) as s58,
sum(s60) as s60,
"{Edit2}" as idOrder,
from table2
where table2.id_order = (select id from table3 where order.desc = "{Edit1}")
group by name

Thanks