Processing application data with SQL