Here is an example for showing how often you died:
prontera,160,168,3 script Statistic NPC 101,{
input @char_name$;
query_sql "SELECT `char_id` FROM `char` WHERE `name`='"+@char_name$+"'", @char_id;
query_sql "SELECT `value` FROM `global_reg_value` WHERE `str`='PC_DIE_COUNTER' AND `char_id`="+@char_id, @die_counter;
mes @char_name$+" died "+@die_counter+" times.";
close;
}
I hope it helps you to understand how sql works here.