0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Leet Code SQL 50 をやってみて

Posted at

My SQLでLeet Code SQL 50をやってみました。
Easy問題なので、ググればなんとかなります。
以下、覚え書きです。
・1581. Customer Who Visited but Did Not Make Any Transactions

select Visits.customer_id, count(Visits.customer_id) as count_no_trans from Visits
left outer join Transactions # leftなので、fromの後のtableへ結合。outerなので、ないものはnull。
on Visits.visit_id = Transactions.visit_id # Tableの結合条件
where Transactions.transaction_id is null # nullの場合のみ表示
group by Visits.customer_id; # countする条件

・1683. Invalid Tweets

select tweet_id from Tweets
where CHAR_LENGTH(content) >15;# 文字数をカウント(My_SQLの場合)

・1148. Article Views I

where author_id = viewer_id
order by id ASC; # 降順にする。昇順はDESC
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?