Create a dynamic list. See the typedlist/view documentation in the manual which discusses the creation of a dynamic list.
An example: fetching the CustomerID and the CompanyName from the customers table:
ResultsetFields fields = new ResultsetFields(2);
fields.DefineField(CustomerFieldIndex.CustomerID, 0, "CustomerID");
fields.DefineField(CustomerFieldIndex.CompanyName, 1, "CompanyName");
and then you just have to fetch it using existing typed list fetch logic, so in SelfServicing this will be:
DataTable results = new DataTable();
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, results, 0, null, null, null, true, null, null, 0, 0);
or if you're using adapter:
DataTable results = new DataTable();
DataAccessAdapter adapter = new DataAccessAdapter();
adapter.FetchTypedList(fields, results, null, 0, null, true, null);
As you can see, you can use filters, group by clauses and what not, even paging