AMQL Docs
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, ...)
Examples
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 and products.id
unique(orders.id, products.id)
orders->idproducts->id
2085670
3685219
27812310
2017363
26280238
45081128
7426270
2106967
10694327
Open in playground ↗

Using unique with select just like group:

Total product by product category
unique(products.name) | select(products.name, count(products.id))
products->namecount_products->id
Chocolate 22
Samsung Tablet 22
H&M T-shirt5
Face Treatment1
Adidas Shoes4
Xbox4
Jordan Shoes2
Bunk Bed2
AFC Biscuits2
Sony Headphone 11
Sofa 13
Body Scrub14
Flour 11
Converse Shoes3
Outdoor Sofa8
Bathroom Mirror1
Face Moisturizers1
Wii1
Cookies 26
Face Cream2
High Cabinet3
Nokia C14
Body Cleanser10
Lacoste T-shirt5
Ticwatch 14
Reebox Shoes2
KitKat 11
Umbrella6
Guess Jeans6
10 Deep T-shirt2
Gucci T-shirt2
Nike Shoes5
Sony Smart TV4
Chips 2. Dried Fruit6
Plant Pot4
Wrangler Jeans3
Baking Soda 11
TV Stand2
iPhone X2
Dining Chair 16
Xbox 3604
Playstation 42
Single Bed1
Oil 26
Apple Watch 17
Samsung Smart TV3
iPhone 72
Kindle Fire 21
Kindle Fire 15
BlackBerry Key 14
Essence Lotions3
Samsung Bluetooth Earphone4
Flour 23
Oil 14
Face Mask1
LG Smart TV2
Samsung Galaxy 24
Bedroom Mirror5
iPad 22
Fireplace4
Chips 17
Panasonic Smart TV6
Outdoor Lighting3
Bathroom Slippers3
Samsung Tablet 11
Shower curtains4
Towels2
Playstation 32
Sony Headphone 22
Samsung Galaxy 12
Smart Lighting2
Nokia C22
Misfit Vapor3
Chocolate 16
Coffee Table4
Lemon Candy2
Lucky T-shirt6
Sofa 23
Calvin Klein Jeans4
Face Masks1
Chocolate Baking4
Face Oil1
Dining Table 25
Cookies 11
Sony Xperia 13
EPTM T-shirt3
Dining Table 12
Queen Bed2
Wardrobe1
Diesel Jeans3
Toshiba Smart TV5
Body Treatments4
Apple Watch 22
Ticwatch 22
Dresser3
Puma Shoes2
Dining Chair 28
LG Bluetooth Earphone 14
Face Serum1
Face Cleanser1
iPad 13
Open in playground ↗

See also

On this page