How to customize the panel for different sources

How can I write a select query if my data is in different databases (web services)? Grafana can do it? Please tell me how it’s done.