在SQL中,要注意哪些作者是我的数据中最受欢迎的作者

时间:2018-04-08 17:37:57

标签: mysql sql database

第一张表

BibNum  ItemBarcode ItemType    Collection  CallNumber  CheckoutDateTime

第二张表

BibNum  Title   Author  ISBN    PublicationYear Publisher   Subjects    ItemType    ItemCollection  FloatingItem    ItemLocation    ReportDate  ItemCount

我需要从读者那里获得最受欢迎的作者,BibNum表示每个读者的帐号。我想我可以在第一个表中使用BibNum,ItemType,在第二个表中使用BibNum,Title,Author,ItemType来使用join或者其他东西。 如果您有任何建议和帮助,请赐教。如果您对表格有任何疑问,请告诉我,我会尽力向您澄清。

以下是每个表格中的示例数据

第一张表

1842225 10035249209 acbk    namys   MYSTERY ELKINS1999  05/23/2005 03:20:00 PM
1928264 10037335444 jcbk    ncpic   E TABACK    12/14/2005 05:56:00 PM
1982511 10039952527 jcvhs   ncvidnf VHS J796.2 KNOW_YO 2000 08/11/2005 01:52:00 PM
2026467 10040985615 accd    nacd    CD 782.421642 Y71T  10/19/2005 07:47:00 PM
2174698 10047696215 jcbk    ncpic   E KROSOCZ   12/29/2005 03:42:00 PM

第二张表

3011076 A tale of two friends / adapted by Ellie O'Ryan ; illustrated by Tom Caulfield, Frederick Gardner, Megan Petasky, and Allen Tam.    O'Ryan, Ellie   1481425730, 1481425749, 9781481425735, 9781481425742    2014    Simon Spotlight,    Musicians Fiction, Bullfighters Fiction, Best friends Fiction, Friendship Fiction, Adventure and adventurers Fiction    jcbk    ncrdr   Floating    qna 09/01/2017  1
2248846 Naruto. Vol. 1, Uzumaki Naruto / story and art by Masashi Kishimoto ; [English adaptation by Jo Duffy]. Kishimoto, Masashi, 1974-   1569319006  2003, c1999.    Viz,    Ninja Japan Comic books strips etc, Comic books strips etc Japan Translations into English, Graphic novels  acbk    nycomic NA  lcy 09/01/2017  1
3209270 Peace, love & Wi-Fi : a ZITS treasury / by Jerry Scott and Jim Borgman. Scott, Jerry, 1955- 144945867X, 9781449458676   2014    Andrews McMeel Publishing,  Duncan Jeremy Fictitious character Comic books strips etc, Teenagers United States Comic books strips etc, Parent and teenager Comic books strips etc, Families Comic books strips etc, Comic books strips etc, Comics Graphic works, Humorous comics   acbk    nycomic NA  bea 09/01/2017  1
1907265 The Paris pilgrims : a novel / Clancy Carlile.  Carlile, Clancy, 1930-  786706155   c1999.  Carroll & Graf, Hemingway Ernest 1899 1961 Fiction, Biographical fiction, Historical fiction    acbk    cafic   NA  cen 09/01/2017  1
1644616 Erotic by nature : a celebration of life, of love, and of our wonderful bodies / edited by David Steinberg.     094020813X  1991, c1988.    Red Alder Books/Down There Press,   Erotic literature American, American literature 20th century    acbk    canf    NA  cen 09/01/2017  1

对于此数据,第二个空格键表示每列的每个值。如果您不知道此示例数据的数据含义,请告诉我,我会尝试清楚地显示。

驱动

| bibnum          | string          | from deserializer |
| title           | string          | from deserializer |
| author          | string          | from deserializer |
| isbn            | string          | from deserializer |
| publicationyear | string          | from deserializer |
| publisher       | string          | from deserializer |
| subjects        | string          | from deserializer |
| itemtype        | string          | from deserializer |
| itemcollection  | string          | from deserializer |
| floatingitem    | string          | from deserializer |
| itemlocation    | string          | from deserializer |
| reportdate      | string          | from deserializer |
| itemcount       | string          | from deserializer

时间表

| bibnum          | string          | from deserializer |
| itembarcode     | string          | from deserializer |
| itemtype        | string          | from deserializer |
| itemcollection  | string          | from deserializer |
| callnumber      | string          | from deserializer |
| checkoutdatetime | string          | from deserializer |

0: jdbc:hive2://localhost:10000/default> SELECT t2.Author
. . . . . . . . . . . . . . . . . . . .> FROM  timesheet t1
. . . . . . . . . . . . . . . . . . . .> INNER JOIN drivers t2
. . . . . . . . . . . . . . . . . . . .> on t1.BibNum = t2.Bibnum
. . . . . . . . . . . . . . . . . . . .> GROUP BY t2.Author
. . . . . . . . . . . . . . . . . . . .> ORDER BY count(t1.Bibnum) DESC 
. . . . . . . . . . . . . . . . . . . .> LIMIT 1;
Error: Error while compiling statement: FAILED: SemanticException [Error 10004]: Line 6:15 Invalid table alias or column reference 't1': (possible column names are: author) (state=42000,code=10004)
0: jdbc:hive2://localhost:10000/default> 

0 个答案:

没有答案