#!/bin/bash

MYSQL='mysql --batch --skip-column-names -uspike -ptar63t -h '

for e in 'aml11' 'aml10' 'aml9' 'aml8' 'aml7' 'aml6' 'aml5' 'aml4' 'aml3' 'aml1'
do

    Q1="select '$e', 'keywords', pc.type, k.status, count(1) from content_editor_google.gce_adGroup g join content_editor_google.gce_keyword k on adGroupID=g.id join content_editor_google.gce_keywordPendingChange pc on keywordID=k.id where g.status='deleted' group by pc.type, k.status"
    Q2="select '$e', 'ads', pc.type, t.status, count(1) from content_editor_google.gce_adGroup g join content_editor_google.gce_textAd t on adGroupID=g.id join content_editor_google.gce_textAdPendingChange pc on textAdID=t.id where g.status='deleted' group by pc.type, t.status"


    $MYSQL "${e}-mysql1" -e "$Q1";
    $MYSQL "${e}-mysql1" -e "$Q2";
done
