我在我的數據庫中產生期望的結果時遇到問題。我想從其他表中提取「總行數」,其中條件將屬於另一個表。要說清楚,下面是示例插圖。在我的方案中需要的正確SQL語句
>tblBus
>
>Bus ID ~ Day~ Type
>
>1000 | Monday | Public
>2000|Monday | Private
>3000|Tuesday| Public
>4000|Monday | Public
>tblReservation
>
>Bus ID | Date
>1000 | 2013/3/4
>2000 | 2013/3/4
>3000 | 2013/3/6
讓說,預訂當天是星期一,這是2013年3月4日..我想顯示所有的公共巴士上可用的週一新行有保留的總數在那輛巴士上製造的。
例如
GeneratedTable(其中date = '2013/3/4',類型= '公共',天= '星期一')
>Bus ID | Day | Type | TotalNumberReservation
>1000 |Monday | Public | 1
>4000 |Monday | Public | 1
'JOIN','GROUP BY'和'COUNT'。 – Wrikken 2013-03-05 19:21:19