[thelist] case statement catch-all? MSSQL

Ken Schaefer Ken at adOpenStatic.com
Wed Aug 24 21:21:13 CDT 2005

: -----Original Message-----
: From: thelist-bounces at lists.evolt.org [mailto:thelist-
: bounces at lists.evolt.org] On Behalf Of Brian Cummiskey
: Subject: Re: [thelist] case statement catch-all? MSSQL
: Matt Warden wrote:
: >>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.
: >
: >
: > 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?
: There are 3 sites listed in the table; char(1)-  C,P, and T for the
: above states.  There are no nulls (if there are, thats another issue :p )
: I need the following results:
: ---------------------------------------------
:   %    %    %              %
: the percent and all that good stuff I can take care of...  i'm just not
: sure how to grab each seperately by the site field, and then basically
: disregard the site field and take everything

Whilst this can be done using T-SQL, as you can see from the various SQL
statements being proposed, it's not the easiest thing to do. It's also not
very efficient.

Your presentation layer code (PHP, .NET, CF) is probably *very* efficient at
adding three numeric values together, and that's all that the final value
(the combined % is). Is it possible to have the presentation layer code add
the values together?


More information about the thelist mailing list