There are two possibilities to manipulate data in a database with the OpenOffice.org database connectivity.
Use the com.sun.star.sdb.RowSet service that allows using data sources defined in OpenOffice.org through their tables or queries, or through SQL commands.
Communicate with a database directly using a Statement object.
Video 6:
The Structured Query Language (SQL) forms the backbone of most modern database systems. These links provide the best resources on the Net for neophytes and expert database administrators alike!
Counting Values in a Database Table with the SQL COUNT Function