我有两张表如下 -
销售记录:
Date | Customer | ItemSold
-----------------------------------------
11/01/2013 | Alex | Pen
12/01/2013 | Rony | Paper
13/01/2013 | Alex | Eraser
14/01/2013 | Marty | Eraser
15/01/2013 | Alex | Pen
16/01/2013 | Rob | Paper
17/01/2013 | Alex | Pencil
18/01/2013 | Alex | Pen
19/01/2013 | Ned | Pen
20/01/2013 | Alex | Paper
21/01/2013 | Alex | Pencil
22/01/2013 | Ned | Pen
23/01/2013 | Alex | Eraser
24/01/2013 | Alex | Pen
25/01/2013 | Alex | Pen
26/01/2013 | Alex | Paper
27/01/2013 | Ned | Paper
28/01/2013 | Alex | Pen
29/01/2013 | Alex | Eraser
30/01/2013 | Alex | Pen
31/01/2013 | Rony | Pencil
01/02/2013 | Alex | Eraser
02/02/2013 | Ned | Paper
03/02/2013 | Alex | Pen
优先:
ItemName | Priority
--------------------------
Pen | 1
Paper | 2
Pencil | 3
Eraser | 4
我想获得一份清单,以了解哪些客户可能会购买以下内容 -
Name | Item
----------------
Alex | Pen
Rob | Paper
Ned | Pen
Marty | Eraser
Rony | Paper
如果与项目有联系,则应选择优先级最高的项目。Ned 每次都买了笔和纸两次,但应该选择笔,因为它比纸更优先。
这将是什么 sql 查询?