在postgresql 8.1升级到9.0之后,我发现了库依赖的问题.Postgresql工作正常(连接,查询).
yum list postgresql*
Installed Packages
postgresql.i386 9.0.0-1PGDG.el5 installed
postgresql-debuginfo.i386 9.0.0-1PGDG.el5 installed
postgresql-devel.i386 9.0.0-1PGDG.el5 installed
postgresql-libs.i386 9.0.0-1PGDG.el5 installed
postgresql-odbcng.i386 0.90.101-2.el5 installed
postgresql-plruby.i386 0.5.1-5.el5 installed
postgresql-server.i386 9.0.0-1PGDG.el5 install
Run Code Online (Sandbox Code Playgroud)
但当我试图为红宝石安装'pg'时,我收到了
gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for pg_config... no
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack …Run Code Online (Sandbox Code Playgroud) 是否有任何选项可以在不使用临时表或过程的情况下获取一个 SQL查询中所有元素的计数组合?
考虑这三个表:
产品(id,product_name)
交易(身份证明,日期)
transaction_has_product(id,product_id,transaction_id)
样本数据
制品
1 AAA
2 BBB
3 CCC
Run Code Online (Sandbox Code Playgroud)交易
1 some_date
2 some_date
Run Code Online (Sandbox Code Playgroud)transaction_has_products
1 1 1
2 2 1
3 3 1
4 1 2
5 2 2
Run Code Online (Sandbox Code Playgroud)结果应该是:
AAA, BBB = 2
AAA, CCC = 1
BBB, CCC = 1
AAA, BBB, CCC = 1
Run Code Online (Sandbox Code Playgroud)