Neidio i'r brif gynnwys

SELECT

yn Anatomy of a DPQL query
Rhestr o awduron
Cyhoeddwyd: May 22, 2018|Diweddarwyd diwethaf: Nov 3, 2022

The SELECT clause works with the WHERE clause to define what information you want your report to include.

It often contains column references which specify the data you want to retrieve from the table you choose in the FROM clause.

See the Appendix for a full list of columns.

For example, suppose you want to produce a table like this of all the tickets that meet a certain condition, e.g. awaiting agent:

../_images/select-table-example.png

Your SELECT clause would be a comma-separated list of column references:

SELECT tickets.id, tickets.subject, tickets.person, tickets.department, tickets.date_created, tickets.agent
copy

The SELECT clause can also use DPQL List Of Functions

For example, suppose you didn’t want a detailed table of all matching tickets, just the total number. You would use the DPQL_COUNT() function to count the total number of matching tickets.

SELECT DPQL_COUNT()
copy

In table output, the header text for a column is automatically derived from the SELECT used to produce the column. This may not always result in a good column name; for example, if you just used SELECT COUNT(), you’ll produce a table like this:

../_images/select-naked-count.png

You can use an alias to specify a better name for a column.

DPQL_COUNT() AS 'Total Tickets'
copy

Would make the result display like this:

../_images/select-count-alias.png

Note


If you want to retrieve all the columns from a table, you can use a wildcard such as SELECT people.

DefnyddiolAnnefnyddiol

Roedd 1 o 1 o bobl yn teimlo bod y dudalen hon yn ddefnyddiol

tudalen nesafFROM
tudalen flaenorolAnatomy of a DPQL query

Mewngofnodwch neu cofrestrwch i gyflwyno sylw.