Ho la seguente tabella:Come contare il numero di righe con dati specifici in mssql
Articoli:
ID Type StockExists
01 Cellphone T
02 Cellphone F
03 Apparrel T
voglio count the number of items
con le scorte esistenti, vale a dire, il numero di righe con StockExists='T'
. Stavo eseguendo la query come;
Select count(StockExists)
From [Items] where StockExists='T'
ma restituisce sempre 1. Qual è il modo giusto per farlo?
Edit:
Inoltre, come eseguire un altro tale operazione Conte e aggiungerli insieme in una riga, per esempio,
Select count(StockExists)
From [Items] where StockExists='T'` and `Select count(Type)
From [Items] where Type='Cellphone'` ?
La tua query sembra soddisfacente [DEMO] (http://sqlfiddle.com/#!6/c0e44/2) – Kaf