Ask Salesforce for the records you need with SOQL: filter with WHERE, order with ORDER BY, count with COUNT(), and walk relationships to related objects
Write your first SOQL queries: SELECT the fields you need, FROM the right sObject, and filter with WHERE to get exactly the records you want