I've an in-memory table that I've populated with data from a custom-format file. I'd like to use this as a repository for the data without duplicating it elsewhere. Each record has a special tag field which can be 1..30. I'd like to create up to 30 virtual 'tables' that I can supply to DBGrid's or DBChart's that look like they each contain the relevant record set corresponding to my tag field. I'm new to database work but know a lot about Delphi so I could DIY a solution and create more in-memory tables using a simple iterative process. I'd rather have something that was a bit more scalable though. I see there is an SQL select statement but on a quick fiddle (using TQuery) I could not see how this would work on an in-memory table (from DevExpress).
Some in-memory tables, like a TClientDataSet, TkbmMemTable, TADMemTable allows to clone the main table. Then you can apply a filter, a sort order, a range to the cloned copy. So, you may have the few virtual views build on the same set of the records. And each view looks like a SELECT * FROM tab WHERE ... ORDER BY ... For details check the help for the method CloneCursor and properties Filter, Filtered, IndexFieldNames, etc.
TQuery cannot use an in-memory table as a datasource. There are few (single ?) other products, like a xQuery, which allows to execute a SQL query against ordinal TDataSet descendants.
Finally, you can load data into some embedded DB, like a SQLite or FB Embedded, then just to make query to this database.