Queries provide a means of asking questions about the features in a data source and getting results that meet the criteria you specify. For example, a query for earthquakes might return which recent earthquakes were of a certain magnitude or greater, or a query for police incident reports can display the calls that have been received in the past 10 minutes.
To configure a query widget, you specify the data source and the query to perform, as well as a title and description. A query widget has a single data source, and all queries for the widget are based on that data source. If you want to define queries against different data sources, you need to create multiple query widgets. If you change the data source when there are existing queries defined for the widget, the existing queries are cleared.
The query can be either simple or parametric, which prompts the user for input. Simple queries use the same query expression each time they are executed. Simple queries are generally performed when a one-time question needs to be asked about a layer, or when the same query needs to be performed on a routine basis because the data associated with the query changes frequently. Parametric queries allow you to specify different criteria for one or more query parameters each time the query is executed. Parametric queries are generally used to allow user input that may vary with each use. You can combine a simple query with a parametric query. For example, you might want to limit demographic information to a particular state, but prompt for the age range, thus producing different results each time the query is executed.
The results of the query can be displayed in a list widget. To do this, you need to add a list widget and set the query result as the data source.
Queries can be defined on any layer based on an ArcGIS map or feature service that has been published with a query service. You can find out if a layer has a query service by referring to the service details.