You can do this using the query method.
Syntax:
query queryname{
description: "Desciption of query"
statement:
//query logic
}
Example:
query Q17 {
description: "Select all drivers aged older than PARAM"
statement:
SELECT org.example.Driver
WHERE (_$ageParam < age)
}
You can find more details here: https://hyperledger.github.io/composer/unstable/reference/query-language