[thelist] case statement catch-all? MSSQL

Matt Warden mwarden at gmail.com
Tue Aug 23 18:30:49 CDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hey Brian,

Brian Cummiskey wrote:
> This may be a simple question, but here goes:
> 
> I need a breakdown by site.
> 
> No problem...
> 
> select
>     case site when 'C' then 'CT' when 'P' then 'PA' when 'T' then 'TX'
> else null end as 'Site'
> from
>     table
> group by
>     site
> 
> 
> works fine and dandy.
> 
> However, There is a 4th column-  "Overall" which includes all 3 sites.
> I'm not sure how to add that into my case statement.
> 
> I tried OR's, I tried when not null, and i tried IN(...) but it didn't
> like any of those.  Can this be done?

OR's should work. Could you give us an idea of what the site "field"
looks like when you want it to say "Overall"? Or did I get that backwards?



- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFDC7GpAQ0d4HGyPE8RAsrKAJ4g5If400vM65I9/mPuOsikW1QbXwCfWAR2
CeuXRawb2snyN30DNBnxhmk=
=bKom
-----END PGP SIGNATURE-----


More information about the thelist mailing list