အားလုံးပဲ မင်္ဂလာပါ။ ဒီနေ့ Day 22 အတွက်ကတော့ Leetcode ရဲ့ difficulties Easy level problem တစ်ပုဒ်ဖြစ်တဲ့ 1148. Article Views I ဆိုတဲ့ problem ကို ရွေးချယ်ထားပါတယ်။ ဒီပုစ္ဆာ မှာတော့ Views table ပေးထားပါတယ်။
1Table: Views2 3+---------------+---------+4| Column Name | Type |5+---------------+---------+6| article_id | int |7| author_id | int |8| viewer_id | int |9| view_date | date |10+---------------+---------+11There is no primary key (column with unique values) for this table, the table may have duplicate rows.12Each row of this table indicates that some viewer viewed an article (written by some author) on some date. 13Note that equal author_id and viewer_id indicate the same person.ကျွန်တော်တို့လုပ်ပေးဖို့လိုတာကတော့ သူရေးထားတဲ့ article ကို ကိုယ်တိုင်အနိမ့်ဆုံး တစ်ကြိမ် ကြည့်ထားတဲ့ author id တွေကိုရှာပေးရမှာပဲဖြစ်ပါတယ်။
1Example 1:2 3Input: 4Views table:5+------------+-----------+-----------+------------+6| article_id | author_id | viewer_id | view_date |7+------------+-----------+-----------+------------+8| 1 | 3 | 5 | 2019-08-01 |9| 1 | 3 | 6 | 2019-08-02 |10| 2 | 7 | 7 | 2019-08-01 |11| 2 | 7 | 6 | 2019-08-02 |12| 4 | 7 | 1 | 2019-07-22 |13| 3 | 4 | 4 | 2019-07-21 |14| 3 | 4 | 4 | 2019-07-21 |15+------------+-----------+-----------+------------+16Output: 17+------+18| id |19+------+20| 4 |21| 7 |22+------+23 ကျွန်တော်ကတော့ အောက်ကအတိုင်း ရေးဖြစ်ခဲ့ပါတယ်။
1**SQL**2 3SELECT DISTINCT author_id AS 'id' FROM Views4WHERE author_id = viewer_id ORDER BY author_id;ဒီ query လေးမှာဆို ကျွန်တော်က author_id နဲ့ viewer_id တူတာကို ရှာထားခြင်းအားဖြင့် သူ့ article ကို ကိုယ်တိုင်ဝင်ကြည့်တဲ့ author_id တွေရလာပြီပဲဖြစ်ပါတယ်။ သူပြောထားတဲ့ order လေးအတိုင်းရအောင် order id ASC နဲ့စီပေးလိုက်ပါတယ်။ ASC ကတော့ default order ဖြစ်လို့မထည့်လည်းရပါတယ်။ ပြီးတော့ author က သူ့ article ကိုတစ်ကြိမ်ထက်ပိုကြည့်ထားရင် author_id ကတစ်ကြိမ်ထက် ပိုပါနေမှာမို့ SELECT လုပ်တဲ့အချိန်မှာ DISTINCT လေးသုံးထားလိုက်ပါဝယ်။ ဒါဆိုရင် လိုချင်တဲ့အဖြေလေးရရှိသွားပြီပဲဖြစ်ပါတယ်ဗျာ။ Video ကိုတော့အောက်က YouTube link လေးကနေတစ်ဆင့်ဝင်ကြည့်နိုင်ပါတယ်ဗျာ။ Stay safe and see you allပါဗျာ။
30 Days Of LeetCode Database Day 22 - 1148. Article Views I
Watch on YouTubeDiscussion
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

Day 2 - GitHub Actions ရဲ့ အဓိက Concepts များနှင့် Runner အကြောင်း
ပြီးခဲ့တဲ့အပတ် Day 1 တုန်းက ကျွန်တော်တို့ CI/CD ရဲ့ Concept တွေကို အကြမ်းဖျင်း ပြောခဲ့ကြပြီးပြီနော်။ ဒီနေရာမှာ လက်တွေ့မစ...
Day 1 - Software Development ကို ပိုပြီးမြန်စေမယ့် CI/CD
Software တစ်ခုရေးပြီးပြီဆိုရင် "ငါ့စက်ထဲမှာတော့ အလုပ်လုပ်တယ်" ဆိုရုံနဲ့ မပြီးသေးပါဘူး။ User တွေသုံးမယ့် Server ပေါ်ရောက်...

Secure AWS ECR Github Action Using OIDC
Modern DevOps နှင့် Cloud Security တို့မှာ အဓိကဖြစ်လာသည့် Authentication System ယနေ့ခေတ် DevOps, Cloud Engineering, CI/C...

Manual vs Automated Infrastructure: Why "useradd" Still Matters in the Terraform Era
DevOps careerကို လျှောက်နေတဲ့သူတိုင်း Terraform၊ Ansible စတဲ့ Infrastructure as Code (IaC) tools တွေရဲ့ အလုပ်လုပ်နိုင်စွ...
From Surviving to Thriving
“AI ကြောင့် developer အလုပ်ပျောက်သွားမလား?” ဆိုတဲ့ မေးခွန်းကို Junior developer တိုင်း စဉ်းစားဖူးကြမှာပါ။ ဈေးကွက်အခြေအနေ...

