SELECT
Syntax of Analysis Statements
The syntax of a complete analysis statement is as follows:
1 2 3 4 | SELECT [DISTINCT] (* | expression) [AS alias] [, ...] [GROUP BY expression [, ...] [HAVING predicates]] [ORDER BY expression [ASC | DESC] [, ...]] [LIMIT size OFFSET offset] |
SELECT indicates the field to be queried. The following part describes parameters and examples for the SELECT syntax.
Using * to Query All Fields
Use * to query all fields.
1 | * |SELECT * |
| account_number | firstname | gender | city | balance | employer | state | lastname | age |
|---|---|---|---|---|---|---|---|---|
| 1 | Amber | M | Brogan | 39225 | Pyrami | IL | Duke | 32 |
| 16 | Hattie | M | Dante | 5686 | Netagy | TN | Bond | 36 |
| 13 | Nanette | F | Nogal | 32838 | Quility | VA | Bates | 28 |
| 18 | Dale | M | Orick | 4180 | null | MD | Adams | 32 |
Querying Specified Fields
Query the specified fields firstname and lastname.
1 | * |SELECT firstname, lastname |
| firstname | lastname |
|---|---|
| Amber | Duke |
| Hattie | Bond |
| Nanette | Bates |
| Dale | Adams |
Using AS to Define Field Aliases
Use AS to define an alias for a field, renaming account_number to num.
1 | * |SELECT account_number AS num |
| num |
|---|
| 1 |
| 16 |
| 13 |
| 18 |
Using the DISTINCT Statement
Use DISTINCT to remove duplicate values from the age field.
1 | * |SELECT DISTINCT age |
| age |
|---|
| 32 |
| 36 |
| 28 |
Using SQL Functions
Use a SQL function to check the length of the firstname field. For details about functions, see Function.
1 | * |SELECT LENGTH(firstname) as len, firstname |
| len | firstname |
|---|---|
| 4 | Amber |
| 6 | Hattie |
| 7 | Nanette |
| 4 | Dale |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot