အားလုံးပဲ မင်္ဂလာပါ။ ဒီနေ့ Day 20 အတွက်ကတော့ Leetcode ရဲ့ difficulties Easy level problem တစ်ပုဒ်ဖြစ်တဲ့ 586. Customer Placing the Largest Number of Orders ဆိုတဲ့ problem ကို ရွေးချယ်ထားပါတယ်။ ဒီပုစ္ဆာ မှာတော့ Orders table လေးပေးထားပြီးတော့ order_number , customer_numberColumn တွေပါဝင်ပါတယ်။
1Example 1:2 3Input: 4Orders table:5+--------------+-----------------+6| order_number | customer_number |7+--------------+-----------------+8| 1 | 1 |9| 2 | 2 |10| 3 | 3 |11| 4 | 3 |12+--------------+-----------------+13Output: 14+-----------------+15| customer_number |16+-----------------+17| 3 |18+-----------------+19Explanation: 20The customer with number 3 has two orders, which is greater than either customer 1 or 2 because each of them only has one order. 21So the result is customer_number 3.22 ကျွန်တော်တို့လုပ်ပေးရမှာက order record အများဆုံးရှိတဲ့ customer ကိုရှာပေးရမှာပဲဖြစ်ပါတယ်။
ကျွန်တော်က တော့ အောက်ကအတိုင်းလေး ရေးဖြစ်ခဲ့ပါတယ်။
1**SQL**2 3SELECT customer_number FROM Orders 4GROUP BY customer_number5ORDER BY COUNT(order_number) DESC 6LIMIT 1;ပထဆုံးအနေနဲ့ ကျွန်တော်တို့က customer တစ်ယောက်ချင်းစီရဲ့ record တွေကို စုစည်းချင်တော့ customer number နဲ့ Group By လုပ်လိုက်ပါတယ်။ ပြီးရင်တော့ ရရှိလာတဲ့ record တွေကို COUNT function သုံးပြီး DESC စီပေးလိုက်ပါတယ်။ ဒါဆို record အများဆုံး customer မှာက အပေါ်ဆုံးရောက်နေပြီပဲဖြစ်ပါတယ်။ ကျွန်တော်တို့ကတစ်ယောက်ပဲရှာပေးဖို့လို တော့ LIMIT 1 ပေးပြီး တစ်ယောက်ထဲဖြစ်အောင်လုပ်လိုက်ပါတယ်။ ဒါဆိုရင်တော့ ကျွန်တော်တို့လိုချင်တဲ့ order အများဆုံးရှိတဲ့ customer ရရှိလာပြီပဲဖြစ်ပါတယ်ဗျာ။ Video ကိုတော့အောက်က YouTube link လေးကနေတစ်ဆင့်ဝင်ကြည့်နိုင်ပါတယ်ဗျာ။ Stay safe and see you allပါဗျာ။ 30 Days Of LeetCode Database Day 20 - 586. Customer Placing the Largest Number of Orders
Discussion
Join the conversation
How do you feel about this article?
Comments
Sign in to join the conversation
Sign in to be the first to comment!
Share Your Article
Share with your professional network
Recent Articles

AWS - Application Load Balancer
Elastic Load Balancing (ELB) ELB ဆိုတာကတော့ request တွေကို တစ်နေရာတည်းမှ လက်ခံကာ Amazon EC2 instances၊ containers, etc.....

Terraform Day 3: Benefits of Terraform State
Terraform ကိုလေ့လာ တဲ့အခါ ကျွန််တော်တို့ရဲ့ Project Folder ထဲမှာ terraform.tfstate ဆိုတဲ့ ဖိုင်လေးကို တွေ့ဖူးကြပါလိမ့်မယ...

Terraform Day 2: Essential IaC Principles You Must Know
မနေ့ကတော့ Terraform အကြောင်း အကြမ်းဖျင်း Concept ကို ပြောပြခဲ့ပြီးပြီဆိုတော့ ဒီနေ့မှာတော့ Terraform ကို Professional ကျက...

TCP/IP Protocol
အားလုံးပဲမင်္ဂလာပါ။ ဒီနေ့ ကျွန်တော်တို့ TCP/IP Protocol အကြောင်း ဆွေးနွေးသွားပါမယ်။ ပထမဆုံးအနေနဲ့ TCP/IP ရဲ့ History လေး...

Terraform Day 1: Introduction to IAC and Terraform
ကျွန်တော်တို့ cloud အကြောင်း စပြောကြပြီဆိုရင် အရင်ဆုံး ခေါင်းထဲရောက်လာတာ Console ထဲဝင်၊ UI ကနေ ခလုတ်လေးတွေ လိုက်နှိပ်ပြီ...


