Thuta Learning
ရှာဖွေရန်
AdvancedData & Databasesbeginner

MIN() & MAX()

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

MIN() နဲ့ MAX() က numeric/date column တွေထဲက အငယ်ဆုံးနဲ့အကြီးဆုံးတန်ဖိုးကိုရှာဖို့သုံးပါတယ်။ Price အနိမ့်ဆုံး/အမြင့်ဆုံး၊ earliest date/latest date, smallest ID/largest ID တွေရှာတဲ့အခါအသုံးဝင်ပါတယ်။

sql
SELECT MIN(CustomerID) AS SmallestID,
       MAX(CustomerID) AS LargestID
FROM Customers;
You should see
+------------+-----------+ | SmallestID | LargestID | +------------+-----------+ | 1 | 4 | +------------+-----------+ What this code does: Customers table ထဲက CustomerID အနည်းဆုံးနဲ့အများဆုံးကိုရှာပြီး alias name နဲ့ပြပါတယ်။ Practical use: Product table မှာ MIN(price) , MAX(price) သုံးပြီး price range filter ပြနိုင်ပါတယ်။
MIN() & MAX() | Thuta Learning