Hi I have this sql code that runs but I am trying to name the columns but I am still getting the f0_ , f1_ columns
SELECT use_date, (use_source), sum(New_Users), sum(new_policies), sum(total_cost), sum(MT_enrollments), sum(cf_quoted_users)
FROM ( SELECT use_date, use_source, New_Users as New_Users, new_policies as new_policies, total_cost as total_cost, MT_enrollments as MT_enrollments, cf_quoted_users as cf_quoted_users
FROM `spot-pet-production.legacy_exec.legacy_exec_data`) itmenames
group by use_date, use_source, New_Users, new_policies, total_cost, MT_enrollments, cf_quoted_users
order by use_date desc
and the result
Row use_date use_source f0_ f1_ f2_ f3_ f4_
1 2022-04-03 wickfire null null null null 3.0
any help in what is wrong with my code?
CodePudding user response:
Name the columns in the outer query instead. E.g.
SELECT use_date, (use_source), sum(New_Users) as Sum_New_Users, ...