- PostgreSQLカンファレンス 2021 - チュートリアル - https://www.postgresql.jp/jpug-pgcon2021 - 詳細はこちら https://github.com/soudai/pgcon21j-tutorial

We announced Cloudflare Workers in 2017, giving developers access to compute on our network. We were excited about the possibilities this unlocked, but we quickly realized — most real world applications are stateful. Since then, we’ve delivered KV, Durable Objects, and R2, giving developers access to various types of storage. Today, we're excited to announce D1, our first SQL database. While the w
Rails Developers Meetup 2017で発表した「Rails❤️SQL」のサンプルコードです。 スライド スライドはこちらにあります。この記事とあわせてどうぞ。 Rails❤️SQL #railsdm // Speaker Deck 1. ちょっと凝った検索条件 Formモデル target_none?やxxx_selected?は独自のprivateメソッドです(コード例は省略)。 class ProjectSearchForm include ActiveModel::Model attr_accessor :keyword, :project, :customer, :member def result scope = Project.all if keyword.present? conditions = [] if target_none? || project
0. はじめに Qiitaはじめ、さまざまなところでRailsのActiveRecordの内部結合や外部結合に関する記事がありますが、それらがまとまって存在していると良いリファレンスとなるのではないかと思い本記事を作成しました。 また、Rails5で動作確認しておきながら、Rails5から追加されたleft_outer_joinsなどは載せてません。今後、載せていきたいと思います。 group byやサブクエリ(副問い合わせ)に関しては下記もご参照ください。 ActiveRecordにおけるGROUP BYの使い方 ActiveRecordでサブクエリ(副問い合わせ)と内部結合 0-1. RubyとRailsとPostgreSQLのバージョン $ ruby -v ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15] $ r
I need to do a query and join with all days of the year but in my db there isn't a calendar table. After google-ing I found generate_series() in PostgreSQL. Does MySQL have anything similar? My actual table has something like: date qty 1-1-11 3 1-1-11 4 4-1-11 2 6-1-11 5 But my query has to return: 1-1-11 7 2-1-11 0 3-1-11 0 4-1-11 2 and so on ..
Eureka EngineeringLearn about Eureka’s engineering efforts, product developments and more.
累計ってプログラム作るしかないと思ってたけど、SQLだけで普通にできるってことをいまさら知った。 会員数の推移を把握したい場合の例 usersテーブル id name created_at '1','user1','2014-10-20 18:17:53' '2','user2','2014-10-20 18:17:57' '3','user3','2014-10-21 18:18:03' '4','user4','2014-10-22 18:18:14' '5','user5','2014-10-22 18:18:18' 日毎に集計する select date_format(a.created_at, '%Y-%m-%d') as created_on, count(*) as count from users a group by created_on order by created
できれば使用しているRDBMSとサンプルデータ、それと期待する結果も載せてほしかったです。 とりあえず、「たぶんこういうことかな?」と想像しながら回答します。 まずこんなテストコードを書きました。 require 'test_helper' class StatusTest < ActiveSupport::TestCase test "ユーザー別に最新のレコードを集計する" do alice = User.create!(name: 'Alice') bob = User.create!(name: 'Bob') alice_status_1 = alice.statuses.create!( logged_in: '2015-01-01 00:00:00', logged_out: '2015-01-01 01:00:00') alice_status_2 = alice.status
前書き - インデックスの作成はなぜ開発者のタスクなのか インデックスの 内部構造 - インデックスは何に似ているか インデックス リーフノード - 二重連結リスト 検索 ツリー(Bツリー) - バランス木 遅いインデックス パートI - インデックスを遅くする2つの原因 where 句 - 検索のパフォーマンスを改善するためにインデックスを作成 等価 演算子 - 一致するキーの検索 プライマリキー - インデックスの使い方を確認 複合インデックス - 複数列に対するインデックス 遅いインデックス パートII - 前の問題点が再び 関数 - where句の 中での関数 大文字・小文字を区別する 検索 - UPPERと LOWER ユーザ定義 関数 - 関数インデックスの制限 インデックスの作り過ぎ - 冗長性の排除法 パラメータ化 クエリ - セキュリティとパフォーマンスのために 範囲 検
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く