Which station has the highest number of stores? Calculate the said station's average maximum temperature in February 2012.
station with highest number of stores refers to station_nbr where Max(Count(store_nbr)); station refers to station_nbr; in February 2012 refers to substring (date, 1, 7) = '2012-02'; average maximum temperature = Divide(Sum(tmax), 29)
SELECT CAST(SUM(T2.tmax) AS REAL) / 29 FROM ( SELECT station_nbr FROM relation GROUP BY station_nbr ORDER BY COUNT(store_nbr) DESC LIMIT 1 ) AS T1 INNER JOIN weather AS T2 ON T1.station_nbr = T2.station_nbr WHERE SUBSTR(T2.`date`, 1, 7) = '2012-02'
CREATE TABLE sales_in_weather
(
    date      DATE,
    store_nbr INTEGER,
    item_nbr  INTEGER,
    units     INTEGER,
    primary key (store_nbr, date, item_nbr)
);
CREATE TABLE weather
(
    station_nbr INTEGER,
    date        DATE,
    tmax        INTEGER,
    tmin        INTEGER,
    tavg        INTEGER,
    depart      INTEGER,
    dewpoint    INTEGER,
    wetbulb     INTEGER,
    heat        INTEGER,
    cool        INTEGER,
    sunrise     TEXT,
    sunset      TEXT,
    codesum     TEXT,
    snowfall    REAL,
    preciptotal REAL,
    stnpressure REAL,
    sealevel    REAL,
    resultspeed REAL,
    resultdir   INTEGER,
    avgspeed    REAL,
    primary key (station_nbr, date)
);
CREATE TABLE relation
(
    store_nbr   INTEGER
            primary key,
    station_nbr INTEGER,
    foreign key (store_nbr) references sales_in_weather(store_nbr),
    foreign key (station_nbr) references weather(station_nbr)
);
