|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Hi!
I have a Customers table with these fields: CustomerID CustomerName I would like to know with a single query how many of my Customers are named John and how many are not. It seems a very basic query to me but I can't figure it out without using temporary tables. Regards, Emmanuel |
|
#2
|
|||
|
|||
|
Code:
select sum(case when customerName = 'John' then 1 else 0 end) as Johns, sum(case when customerName = 'John' then 0 else 1 end) as nonJohns from customers |
|
#3
|
|||
|
|||
|
That did it!!!
Thanks a lot!!! Emmanuel |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > SQL Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|