Input As
=====================
city1 city2 distance
=====================
Raipur Goa 500
Goa Raipur 500
Manik Jamui 200
Jamui Manik 200
Noida Pune 100
Output:
=====================
city1 city2 distance
=====================
Raipur Goa 500
Jamui Manik 200
Noida Pune 100
對于 Raipur 和 Goa,在輸入資料中有 2 行,Manik 和 Jamui 也是如此。在輸出中,它應該只獲取 1 行。如何為上述輸入創建 SQL 查詢以獲得所需的輸出。
uj5u.com熱心網友回復:
試試這個:
select distinct greatest(city1, city2) as city1, least(city1, city2) as city2, distance
from Input
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/418511.html
標籤:
上一篇:如何在不使用ASC或DESC的情況下對資料庫值進行排序
下一篇:取決于值的列總和
