List:General Discussion« Previous MessageNext Message »
From:Gobi Date:November 29 2005 1:16am
Subject:Re: How to use 'if' in select
View as plain text  
SGreen@stripped wrote:

>Wouldn't it be just as simple to count all 'neg', 'pos', and 'ind' values 
>for both columns? By the way, is there some other column you are grouping 
>by or is it always going to apply to entire tables of information?
>
>I know this is not what you wanted. However, what you want still isn't 
>very clear to me but this might help you get better data for your 
>application to make decisions from:
>
>SELECT 
>   sum(if(status1='neg',1,0)) as neg1
>  ,sum(if(status1='pos',1,0)) as pos1
>  ,sum(if(status2='neg',1,0)) as neg2
>  ,sum(if(status2='pos',1,0)) as pos2
>  ,sum(if(status2='neg' AND status1='neg',2,0)) as neg_both
>FROM dummy;
>
>If you had another column in your data like a patientID or a groupID it 
>would be very simple to add that column and group by that value with this 
>query. As I said, what you are trying to get at is still fuzzy for me 
>(because you oversimplified the real issue).
>
>Shawn Green
>Database Administrator
>Unimin Corporation - Spruce Pine
>  
>

Thanks for your input.  I think your method may work.  Let me try it 
when I get into the office.

Thread
How to use 'if' in selectGobi28 Nov
  • Re: How to use 'if' in selectFelix Geerinckx28 Nov
    • Re: How to use 'if' in selectGobi28 Nov
      • Re: How to use 'if' in selectSGreen28 Nov
        • Re: How to use 'if' in selectGobi29 Nov
        • Re: How to use 'if' in selectGobi29 Nov
          • Re: How to use 'if' in select [solved]Gobi29 Nov