1. Usually a GROUP BY SQL query requires that all none-aggregate function columns in the SELECT clause should be specified into the GROUP BY clause. I .e. in your case it should be something like this:
Code: Select all
select
`account`,
`campaign`,
SUM(`clicks`) as `clicks`,
SUM(`impressions`) as `impressions`,
AVG(`avg_position`) as `avg_pos`,
SUM(`cost`) as `cost`,
SUM(`conv_mpc`) as `conversions`,
MIN(`date`) as `week_start_date`
FROM
ppc_data
where
campaign ='Aftershave High'
GROUP BY
`account`,
`campaign`,
WEEK(`date`)
though it will GRUOP BY not only by week, but also by account and campaign. I think it's not the desired result, so you may want to remove account and campaign columns from SELECT and GROUP BY clause.
2. Always put column names in
backsticks (is that the proper word???) like I did in the above query. WEEK, DATE are SQL keywords ...
3. Avoid doing output formatting in SQL queries ( CONCAT(date, ' -', date + INTERVAL 6 DAY) )