考慮,列出了一些書的作者如下:PostgreSQL的 - 計數行
Table
name bookid
---------------
Alan 1
Bob 1
Charlie 2
David 2
我想找出一個人有多少合着者擁有他的整本書線。例如,如果小李寫了兩本書,一本與Bob,另一個與查理+大衛,那麼他的總合着者數量應爲3
我想什麼(但不工作):
select t1.name, count(t2.name)
from table t1, table t2
where t1.bookid = t2.bookid
任何幫助球員?非常感激。
那你試試? – 2014-09-22 07:40:38
從表t1中選擇t1.name,count(t2.name),表t2其中t1.bookid = t2.bookid – antikbd 2014-09-22 07:42:43
家庭作業?這是[教程級別資料](http://www.postgresql.org/docs/current/static/tutorial.html)。 – 2014-09-22 07:49:09