Home > Back-end >  Distinct and Min
Distinct and Min

Time:01-06

I'm writing a query that has MIN and DISTINCT in my SELECT in BigQuery.

Example:

SELECT
  MIN(a),
  DISTINCT(b),
  c,
  d

BQ is telling me it expected the input to end but instead found DISTINCT. Anyone know why I can't use the DISTINCT function after MIN?

CodePudding user response:

can u try this, i think DISTINCT is first and then func MIN

SELECT DISTINCT(b), MIN(a), c, d

CodePudding user response:

if u run sql DISTINCT function after MIN, MIN will be filter 1 data and then DISTINCT not working, u must be run DISTINCT at first and then from the DISTINCT will be search with function MIN

SELECT DISTINCT(b), MIN(a), c, d from NameOfTable
  •  Tags:  
  • Related