query data using sql and active record interface