0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

100日でSQLの達人になる@LeetCode! Day6 <mod() or %>

Last updated at Posted at 2022-02-07

620. Not Boring Movies (問題レベル: Easy)

今日の問題はこれ。
IDが奇数かつ、降順にリストアップするという問題。

全体のクエリ構造は非常に簡単だが、奇数の判定と降順のクエリを忘れていた。

ポイントは

MySQL
mod(ID,2) = 1

とMySQLではmod関数が使えるが、SQL Serverでは、次のように記載しないと駄目。

SQLServer
ID % 2 = 1

また、降順のコマンドは

SQLServer
order by rating desc

descendingとフルスペルしては駄目!また、記載する順も重要。
昨日早速サボってしまったため、今日は二つ投稿した。

  • LeetCodeの問題は、MS SQL Serverで解いています。
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?