Each GROUP BY expression must contain at least one column that is not an outer reference

前端 未结 7 1794
-上瘾入骨i
-上瘾入骨i 2020-12-09 07:50

What am I doing wrong here? I am getting this error on:

SELECT LEFT(SUBSTRING(batchinfo.datapath, PATINDEX(\'%[0-9][0-9][0-9]%\', batchinfo.datapath), 8000),         


        
7条回答
  •  渐次进展
    2020-12-09 08:49

    I think you're not using GROUP BY properly.

    The point of GROUP BY is to organize your table into sections based off a certain column or columns before performing math/aggregate functions.

    For example, in this table:

    Name    Age   Salary
    Bob     25     20000
    Sally   42     40000
    John    42     90000
    

    A SELECT statement could GROUP BY name (Bob, Sally, and John would each be separate groups), Age (Bob would be one group, Sally and John would be another), or Salary (pretty much same result as name).

    Grouping by "1" doesn't make any sense because "1" is not a column name.

提交回复
热议问题