與特定的數據行數我有如下表:如何計算在MSSQL
項目:
ID Type StockExists
01 Cellphone T
02 Cellphone F
03 Apparrel T
我想count the number of items
與現有的股票,即行與StockExists='T'
數。我正在執行查詢;
Select count(StockExists)
From [Items] where StockExists='T'
但它總是返回1.什麼是正確的方法來做到這一點?
編輯:
此外,如何執行另一個這樣的計數操作,並加在一起他們在一排,例如,
Select count(StockExists)
From [Items] where StockExists='T'` and `Select count(Type)
From [Items] where Type='Cellphone'` ?
你的查詢看起來很好[DEMO](http://sqlfiddle.com/#!6/c0e44/2) – Kaf