我尝试了以下SQL查询,并且出现以下错误:
Select TOP 1 CITY,MAX(LEN(CITY))
from STATION
ORDER BY CITY ASC
错误
选择列表中的“ STATION.CITY”列无效,因为该列未包含在聚合函数或GROUP BY子句中。
表:
CREATE TABLE City (
ID Integer NOT NULL,
PRIMARY KEY (ID),
Name VARCHAR (255),
CountryCode VARCHAR (255),
District VARCHAR (255),
PopulationofCity Integer
);
答案 0 :(得分:0)
您必须分组分组城市
Select TOP 1 CITY,MAX(LEN(CITY))
from STATION group by CITY
ORDER BY CITY ASC
答案 1 :(得分:0)
您缺少分组依据
Select TOP 1 CITY,MAX(LEN(CITY)) from STATION
group by city
ORDER BY CITY ASC
答案 2 :(得分:0)
您可能正在寻找最长的城市名称。
然后按降序排列
SELECT TOP 1 CITY, LEN(CITY)
FROM STATION
GROUP BY CITY
ORDER BY LEN(CITY) DESC
答案 3 :(得分:0)
有帮助吗?
<p-dropdown [options]="cars" [(ngModel)]="selectedCar2" filter="true">
<ng-template let-item pTemplate="selectedItem">
<img src="assets/showcase/images/demo/car/{{item.label}}.png" style="width:16px;vertical-align:middle" />
<span style="vertical-align:middle; margin-left: .5em">{{item.label}}</span>
</ng-template>
</p-dropdown>