<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://wiki.hgotoh.jp/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>努力したWiki - documents:proglang:sql</title>
        <description>推敲の足りないメモ書き多数</description>
        <link>https://wiki.hgotoh.jp/</link>
        <lastBuildDate>Sat, 09 May 2026 13:44:23 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://wiki.hgotoh.jp/_media/wiki/logo.png</url>
            <title>努力したWiki</title>
            <link>https://wiki.hgotoh.jp/</link>
        </image>
        <item>
            <title>SQLでデータベーステーブルの縦･横変換</title>
            <link>https://wiki.hgotoh.jp/documents/proglang/sql/sql-0001</link>
            <description>SQLでデータベーステーブルの縦･横変換

2006年07月10日

クエリを思いつかなかった子のために。これはあくまでヒントだぞ。
以降の例では Oracle9iリリース２で説明しています。

テーブルの横→縦変換</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 08 May 2026 12:19:12 +0000</pubDate>
        </item>
        <item>
            <title>SQLで各グループ中の最大値を持つレコードに印を付けたい</title>
            <link>https://wiki.hgotoh.jp/documents/proglang/sql/sql-0006</link>
            <description>SQLで各グループ中の最大値を持つレコードに印を付けたい

2014年8月29日

Oracle 11g Release 11.1 で説明しています。

お客さんへの説明でいろいろやったんでついでに自分の資料用に作ってしまった。</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 08 May 2026 12:19:12 +0000</pubDate>
        </item>
        <item>
            <title>SQLでTOP3ランキングをやりたい</title>
            <link>https://wiki.hgotoh.jp/documents/proglang/sql/sql-0008</link>
            <description>SQLでTOP3ランキングをやりたい

2016年8月14日

PostgreSQL 9.5.4 で説明してますが、Oracle でも可能な筈。

夏休み直前に後輩Hシー氏から振られた話題を記録しておく。



下準備

今回のデータは、</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 08 May 2026 12:19:22 +0000</pubDate>
        </item>
        <item>
            <title>SQLで時間の集計を行う</title>
            <link>https://wiki.hgotoh.jp/documents/proglang/sql/sql-0009</link>
            <description>SQLで時間の集計を行う

2017年10月24日

ちょっと調べものしてしまったので自分用メモ。

処理対象データ

PostgreSQLに以下のデータがある。


$ psql -h dbsvr05 kamonohashi kamo
psql (9.5.9, サーバー 9.6.1)
WARNING: psql major version 9.5, server major version 9.6.
         Some psql features might not work.
&quot;help&quot; でヘルプを表示します.

kamonohashi=&gt; \d timelog
       テーブル &quot;public.timelog&quot;
  列  |          型          |  修飾語
------+----------------------+----------
 id   | integer              | not null
 grp  | character varying(3) |
 time | character varying(5) |
イン…</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 08 May 2026 12:19:13 +0000</pubDate>
        </item>
        <item>
            <title>SQLで不足レコードを補うクエリの発行</title>
            <link>https://wiki.hgotoh.jp/documents/proglang/sql/sql-0010</link>
            <description>SQLで不足レコードを補うクエリの発行

2017年11月16日

自分用メモ。

処理対象データ

PostgreSQLに以下のデータがある。


$ psql -h 192.168.1.30 kamonohashi kamo
psql (9.6.5)
&quot;help&quot; でヘルプを表示します.

kamonohashi=&gt; select * from salelog;
         day         | item  | qty
---------------------+-------+-----
 2017-10-01 00:00:00 | ITEM1 |  30
 2017-10-02 00:00:00 | ITEM2 |  15
 2017-10-02 00:00:00 | ITEM3 |  20
 2017-10-11 00:00:00 | ITEM1 |  25
 2017-10-13 00:00:00 | ITEM1 |  15
 2017-10-13 00:00:00 | ITEM2 |   5
(6 行)

kamonohashi=&gt;…</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 08 May 2026 12:19:13 +0000</pubDate>
        </item>
        <item>
            <title>SQLで移動平均を算出</title>
            <link>https://wiki.hgotoh.jp/documents/proglang/sql/sql-0011</link>
            <description>SQLで移動平均を算出

2020/01/08

平均値格納行がおかしかったので修正。

2020/01/08

職場のTRSHM君に煽られたんでちょっと書く。

概要

	*  直近3日の移動平均を出すサンプルコードを掲示する。</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 08 May 2026 12:19:13 +0000</pubDate>
        </item>
        <item>
            <title>SQLで指定時間幅でまとめる</title>
            <link>https://wiki.hgotoh.jp/documents/proglang/sql/sql-0014</link>
            <description>SQLで指定時間幅でまとめる

2024/03/19 おまけ追加

2024/03/18 ヒントだけ

サンプルデータ

こういうデータがあったとします。



連続した2秒以内の塊を得る

項目DEVID毎に、連続した2秒以内のレコード群を一つのグループに纏めたいという要求がありました。</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 08 May 2026 12:20:16 +0000</pubDate>
        </item>
        <item>
            <title>137.SQL関連</title>
            <link>https://wiki.hgotoh.jp/documents/proglang/sql/start</link>
            <description>137.SQL関連</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 08 May 2026 12:19:57 +0000</pubDate>
        </item>
    </channel>
</rss>
