答案 0 :(得分:0)
如果只有3个不同的city_size,你可以像下面这样做。
假设同一AREA_NAME
area
也相同。
select area,area_name
,max(case when city_size=1
then rate
else null end
) as city_size_1_rate
,max(case when city_size=2
then rate
else null end
) as city_size_2_rate
,max(case when city_size=3
then rate
else null end
) as city_size_3_rate
from your_table
group by area,area_name;
说明:case when city_size=1 then rate else null end
只会rate
为city_size=1
提供null
,但它会为您提供group by
。当您area
max
并选择rate
或更高价值时,您将只获得非空city_size_1_rate
,即 private async void btnProcessFIle_Click(object sender, EventArgs e)
{
var task = Task.Run(() => {
var count = countCharacters();
lblCount.BeginInvoke((Action) (() =>
{
lblCount.Text = "No. of characters in file=" +Environment.NewLine+
count.ToString();
}));
});
await task;
}
。同样适用于其他2列。
答案 1 :(得分:0)
你应该在这里使用分组
SELECT area,area_name,city_size1 rate,city_size2 rate,city_size3 rate FROM your_table_name GROUP BY area;
group by可以执行:
area
的每个值存储在a中
哈希表如此优化速度,但可能需要大量内存。