Wikia

Familypedia

Help:Inline queries/Sorting results

Talk0
136,530pages on
this wiki

< Help:Inline queries

Subpages of the main Help page:
* 1 /Introduction to "hash"ask
* 2 /The "hash"show parser function
* 3 /Standard parameters for inline queries
**3.1 /Result limits and links to further results
**3.2 /Introduction and default text

**3.3 /Sorting results

**3.4 /Configuring labels or table headers
**3.5 /Changing the first result column
* 4 /Result formats
* 5 /Exporting query results: RSS, etc.
* 6 /Using templates for custom formatting

It has been explained in Help:Selecting pages that query results can be ordered by one or more properties. As explained there, Special:Ask has additional input fields to specify sort properties and ordering. In inline queries, sort properties are defined with the parameter sort, and the order can be set with the parameter order. The value of order should be ascending or descending, or one of the short forms «asc» and «desc», or «reverse». An example is the following query for the three largest cities in Germany:

{{#ask: [[Category:City]] [[Located in::Germany]]
 | ?Population
 | sort=Population
 | order=descending
 | limit=3
}}

As explained in Help:Selecting pages, sorting conditions may impose restrictions on the set of query results. In the above case, only German cities that have a value for population are considered. If more than one property is used for sorting, the parameters sort and order can be set to lists of property names and orders, repsectively, separated by commas. The following is an example:

{{#ask: [[Category:City]] [[Located in::Germany]]
 | ?State
 | ?Population
 | sort=State,Population
 | order=ascending,descending
}}

This query would return all German cities for which a state and population was specified. These results will be ordered by the name of the state they are located in (ordered alphabetically). Cities that are located in the same state will be ordered by their population, largest first («descending»).


This page uses content from the Semantic MediaWiki website. The original content was at Help:Inline queries. The list of authors can be seen in the page history there. The documentation portion of the content of Semantic MediaWiki is available under Creative Commons 3.0 licensing.

Photos

Add a Photo
32,315photos on this wiki
See all photos >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki