我試圖得到一個單一的一個內的兩個請求的結果,這兩個以下要求功能齊全,他們每個人都得到一個表格有兩列:替補2 SQL/ORACLE請求只由一個請求
SELECT patron.last_name, COUNT(*) AS **pret**
FROM circ_transaction_log INNER JOIN patron ON circ_transaction_log.patron_id=patron.patron_id
AND **circ_transaction_log.transaction_type<5**
AND patron.college_or_school = 'High School'
GROUP BY patron.last_name;
姓氏 | pret
________________
steven grelle | 552
michelle vins | 122 ...
_________________________ OR _________________________
SELECT patron.last_name, COUNT(*) AS **resa**
FROM circ_transaction_log INNER JOIN patron ON circ_transaction_log.patron_id=patron.patron_id
AND **circ_transaction_log.transaction_type BETWEEN 5 AND 10**
AND patron.college_or_school = 'High School'
GROUP BY patron.last_name;
姓氏 | resa
________________
steven grelle | 12
michelle vins | 8
...
我希望得到的結果是有點像這樣:
姓氏 | resa | pret
_______________________________
steven grelle | 552 | 12
michelle vins | 122 | 8
...
但我認爲困難是,我請求同一個表兩次枝條計數(表CIRC_TRANSACTION_LOG)和任何我想是或者錯誤或不提前工作
謝謝您回覆
問候, Nickk
MySQL和SQL Server和Oracle?你真的使用這3個? – jarlh 2015-02-10 12:10:57
在last_name上加入你的兩個請求(查詢) – 2015-02-10 12:11:22