0

我非常接近这个查询(SQL Server 2008 R2):

Select selectedicao, selectedyear, selectedmonth
From weatherdaily
Where Selectedyear = 1990 and selectedmonth = 1
Group By selectedicao, selectedyear, selectedmonth

输出:

selectedicao    selectedyear    selectedmonth
-------------------------------------------------
KPKB            1990            1
KORD            1990            1
KFWA            1990            1
KCDW            1990            1
KFDY            1990            1
KLCK            1990            1

我只需要在另一个名为kfactor.

该列对于每个组都有数百个值,我无法在上述查询中为每个组列出一个值。

4

1 回答 1

2

我认为您只需要添加该max()功能。

Select selectedicao, selectedyear, selectedmonth, max(kfactor) as max_kfactor
From weatherdaily
Where Selectedyear = 1990 and selectedmonth = 1
Group By selectedicao, selectedyear, selectedmonth
于 2013-02-18T17:59:51.153 回答