you can use a lookup activity to query any SQL statement from your SQL serve
Then use
@activity('Lookup1').output
to reference the value in other activities.
In case if you want to copy this query from 1 source to another, no need of lookup activity,
within copy activity source SQL aspect only, you can have your select query and you can map your sink as needed