AQL ReferenceFunctionsTable functions
unique
AQL Syntax: To return unique values
Definition
Return a new table with all unique combination of values in the specified dimensions. It is similar to group but without the need to specify a source table. The difference is that group will only return combination of values that exist with respect to the source table, while unique will choose the source table with the most number of rows.
Syntax
unique(dimension, dimension, ...)unique(orders.id, products.id) // -> Table(orders.id, products.id)
unique(orders.id, products.id, customers.id) // -> Table(orders.id, products.id, customers.id)Input
dimension(repeatable): A fully-qualified reference to a dimension. The output table will have one row for each unique combination of values in the specified dimensions.
Output
A new table with one row for each unique combination of values in the specified dimensions.
Sample Usages
unique(orders.id, products.id)| orders->id | products->id |
|---|---|
| 20856 | 70 |
| 36852 | 19 |
| 27812 | 310 |
| 20173 | 63 |
| 26280 | 238 |
| 45081 | 128 |
| 7426 | 270 |
| 21069 | 67 |
| 10694 | 327 |
Using unique with select just like group:
unique(products.name) | select(products.name, count(products.id))| products->name | count_products->id |
|---|---|
| Chocolate 2 | 2 |
| Samsung Tablet 2 | 2 |
| H&M T-shirt | 5 |
| Face Treatment | 1 |
| Adidas Shoes | 4 |
| Xbox | 4 |
| Jordan Shoes | 2 |
| Bunk Bed | 2 |
| AFC Biscuits | 2 |
| Sony Headphone 1 | 1 |
| Sofa 1 | 3 |
| Body Scrub | 14 |
| Flour 1 | 1 |
| Converse Shoes | 3 |
| Outdoor Sofa | 8 |
| Bathroom Mirror | 1 |
| Face Moisturizers | 1 |
| Wii | 1 |
| Cookies 2 | 6 |
| Face Cream | 2 |
| High Cabinet | 3 |
| Nokia C1 | 4 |
| Body Cleanser | 10 |
| Lacoste T-shirt | 5 |
| Ticwatch 1 | 4 |
| Reebox Shoes | 2 |
| KitKat 1 | 1 |
| Umbrella | 6 |
| Guess Jeans | 6 |
| 10 Deep T-shirt | 2 |
| Gucci T-shirt | 2 |
| Nike Shoes | 5 |
| Sony Smart TV | 4 |
| Chips 2. Dried Fruit | 6 |
| Plant Pot | 4 |
| Wrangler Jeans | 3 |
| Baking Soda 1 | 1 |
| TV Stand | 2 |
| iPhone X | 2 |
| Dining Chair 1 | 6 |
| Xbox 360 | 4 |
| Playstation 4 | 2 |
| Single Bed | 1 |
| Oil 2 | 6 |
| Apple Watch 1 | 7 |
| Samsung Smart TV | 3 |
| iPhone 7 | 2 |
| Kindle Fire 2 | 1 |
| Kindle Fire 1 | 5 |
| BlackBerry Key 1 | 4 |
| Essence Lotions | 3 |
| Samsung Bluetooth Earphone | 4 |
| Flour 2 | 3 |
| Oil 1 | 4 |
| Face Mask | 1 |
| LG Smart TV | 2 |
| Samsung Galaxy 2 | 4 |
| Bedroom Mirror | 5 |
| iPad 2 | 2 |
| Fireplace | 4 |
| Chips 1 | 7 |
| Panasonic Smart TV | 6 |
| Outdoor Lighting | 3 |
| Bathroom Slippers | 3 |
| Samsung Tablet 1 | 1 |
| Shower curtains | 4 |
| Towels | 2 |
| Playstation 3 | 2 |
| Sony Headphone 2 | 2 |
| Samsung Galaxy 1 | 2 |
| Smart Lighting | 2 |
| Nokia C2 | 2 |
| Misfit Vapor | 3 |
| Chocolate 1 | 6 |
| Coffee Table | 4 |
| Lemon Candy | 2 |
| Lucky T-shirt | 6 |
| Sofa 2 | 3 |
| Calvin Klein Jeans | 4 |
| Face Masks | 1 |
| Chocolate Baking | 4 |
| Face Oil | 1 |
| Dining Table 2 | 5 |
| Cookies 1 | 1 |
| Sony Xperia 1 | 3 |
| EPTM T-shirt | 3 |
| Dining Table 1 | 2 |
| Queen Bed | 2 |
| Wardrobe | 1 |
| Diesel Jeans | 3 |
| Toshiba Smart TV | 5 |
| Body Treatments | 4 |
| Apple Watch 2 | 2 |
| Ticwatch 2 | 2 |
| Dresser | 3 |
| Puma Shoes | 2 |
| Dining Chair 2 | 8 |
| LG Bluetooth Earphone 1 | 4 |
| Face Serum | 1 |
| Face Cleanser | 1 |
| iPad 1 | 3 |