If your data is in a PostGIS or Spatialite database you can use the DB Manager plugin to run queries like that. You can also use it to generate layers from spatial queries if your query result includes a unique integer field for IDs and a geometry column.
If your data is in shapefiles you can use sqlite's virtual table function. From the command prompt go to the directory your shapefiles are stored in and start the sqlite3 console. Use
SELECT load_extension('libspatialite.so');
if you're on a linux or OS X machine or
SELECT load_extension('libspatialite.dll');
if you're using Windows.
Once spatialite is enabled use
CREATE VIRTUAL TABLE <table_name> USING VirtualShape(<shapefile_name>, 'UTF-8', <srid>);
to make your virtual table. From there you can run any read-only spatial query you like on your shapefile data.