sql - Selected non-aggregate values must be part of the associated group -


i have 2 tables in teradata: table_a , table_b. between them left join. afterwards making select statement contains attributes both tables:

select attribute_1 attribute_2 ... attribute_n 

afterwords, using sum functions calculations. these functions this:

sum ( case when attribute_1 > 2 attribute_2*1.2 else 0 end 

(in example attributes in select part used).

but use in case part attributes not in select statement - liek this:

sum ( case when attribute_x > 2 attribute_y*1.2 else 0 end 

of course @ end doing group 1,2,...,n

the error getting "selected non-aggregate values must part of associated group." furtheremore, have checked billion times number of selected attributes in select part, , n. question - why getting error? because using in sum part i.e. case part attributes (attribute_x , attribute_y) not included in select part?

blueprint of end-statement looks sthg. this:

insert table_new  select attribute_1, attribute_2, ... attribute_n,  sum ( case when attribute_1 > 2 attribute_2*1.2 else 0 end ) sum_a,  sum ( case when attribute_x > 2 attribute_y*1.2 else 0 end ) sum_x  table_a left join table_b on ...  group 1,2,...,n 

the error message suggests have not included non-aggregate columns listed in select statement in group by expression. i'm guessing have more columns listed have "place holders".

the best way avoid explicitly name columns , not use "relative positioning" syntax. in other words, rather using group 1,2,...n use:

group    attribute_1,    attribute_2,    ...    attribute_n 

if not fix problem, modify question , show complete query not working.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -