1
A
回答
0
SELECT c.Brand COUNT(plate_number) FROM car as c LEFT JOIN (borrow as b) on c.cid = b.id WHERE endDate < NOW() GROUP BY c.Brand
我沒有嘗試它,但它應該工作。
編輯:固定在哪裏。
0
halfpseudo計算行或通過使用SQL計數或組,左也一同適用其中nullvalues
brand from car join borrow on borrow.brand=car.brand where endDate<currentdate
0
表:
car(plate_number, brand, cid)
borrow(StartDate, endDate, brand, id)
select c.plate_number, b.brand, count(b.brand) as available_number
from car c, borrow b
where c.brand=b.brand
and end_date>=sysdate
having count(1)>0
group by c.plate_number, b.brand
相關問題
- 1. 需要一個SQL查詢
- 2. 需要單個SQL查詢
- 3. 需要幫助把一個SQL查詢到一個ActiveRecord查詢
- 4. 需要幫助做一個SQL查詢
- 5. 需要幫助寫一個SQL查詢
- 6. 我需要一個SQL查詢
- 7. 我需要一個SQL查詢幫助
- 8. 需要一個SQL查詢幫助
- 9. 需要一個Linq查詢來查詢對應的SQL查詢
- 10. Sql查詢需要
- 11. 我需要查詢的次數。我是否需要寫另一個SQL查詢
- 12. 需要一個MySQL查詢
- 13. 需要一個MySQL查詢
- 14. 需要一個MySQL查詢
- 15. sql查詢 - 需要一些建議
- 16. SQL查詢,我需要一些值
- 17. SQL查詢需要一些幫助
- 18. SQL查詢 - 我需要從查詢
- 19. SQL查詢/子查詢需要幫助
- 20. 需要SQL Server查詢
- 21. SQL - 需要進行查詢
- 22. 需要重寫sql查詢
- 23. 需要SQL查詢輸入
- 24. 需要從SQL查詢值
- 25. sql查詢需要代碼
- 26. SQL查詢 - 需要改進
- 27. SQL查詢需要時間
- 28. 需要使用SQL查詢
- 29. SQL查詢 - 需要建議
- 30. 需要在SQL查詢
聽起來去吧作業問題。你的導師是否知道你在作弊? – 2009-11-29 05:22:51
指定「可用」:對於給定日期? – mjv 2009-11-29 05:24:34
你可能想要考慮用名詞比如「loan」而不是動詞「borrow」來命名你的表。表格通常代表實體(事物)。 – 2009-11-29 06:08:10