sql server - multiple count in a sql query -


I need a report from a database where I need an end result, such as men, women, against city In the end I started with something like the state against the show.

  SELECT p.StateName, d.CityName, as the API at API Inner Join DB.State P as dbo.Application_Personal_information (APJender). State = PIID Inner Join Dabo CT D on API.City = DT Group by P.T.T.NET, DCT   

when I do this

  SELECT p.StateName, d.CityName, count (api.Gender = 'Male) as male, count (api.Gender =' female) as female, dbo.Application_Personal_information as api INNER join dbo.state as p But api.state = p.ID inner jiO dbo.City D on api.City = D.ID Group P. In the form of STATEName, d.CityName   

this gives me an error in the wrong syntax = pass I also select statement

  COUNT (select API from API) where As the man's API Gender = 'male'), but   

but this is not working ... any thoughts?

  SELECT p.StateName, d.CityName, sum (case when gender = 'male' Then 1 and 0 in the form of a man, join the API Inner as math (case when gender = 'female' then 1 and 0) as dhokka dbo.Application_Personal_information as db.state P. api.State = PIID Inner Join Debo CT D on API.c0 = D.ID Group P. Status, DCT name    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -