<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>ku__ra__ge</author_name>
  <author_url>https://blog.hatena.ne.jp/ku__ra__ge/</author_url>
  <blog_title>くらげのChangeLog</blog_title>
  <blog_url>https://culage.hatenablog.com/</blog_url>
  <categories>
    <anon>program</anon>
  </categories>
  <description>分析関数（ウインドウ関数）でグループ内の件数の多い順を求めて、最初のアイテムの値を取得する。 出現数が同じアイテムが複数ある場合にどれか１つではなく全ての最頻値を取得したい場合、ROW_NUMBER()の代わりにRANK()を使う。 分析関数のOVER(ORDER BY xxx)にcount(*)を指定してグループ内の件数順に番号を振ることで実現している。 -- テスト用テーブル作成 CREATE TABLE test ( val VARCHAR(10) ); INSERT INTO test VALUES ('A'); INSERT INTO test VALUES ('B'); INSER…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fculage.hatenablog.com%2Fentry%2F2025%2F07%2F30%2F000000&quot; title=&quot;最頻値を求めるSQL - くらげのChangeLog&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2025-07-30 00:00:00</published>
  <title>最頻値を求めるSQL</title>
  <type>rich</type>
  <url>https://culage.hatenablog.com/entry/2025/07/30/000000</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
