List:General Discussion« Previous MessageNext Message »
From:Steve Edberg Date:May 9 2002 9:52pm
Subject:Re: change displayed text results?
View as plain text  
Hmmm -

Off the top of my head, how about:

    select
       order, if(SUM(cat1+cat2)=0, '-', SUM(cat1+cat2)) as sum
    from
       tbl
    group by
       order

Although you might need to quote the column name 'order', since that 
is a reserved word:

    select
       'order', ...

    group by
       'order'


I think there's probably a cleaner way to do it, but that _should_ work...

	- steve


At 2:55 PM -0200 5/9/02, fabrizio@stripped wrote:
>Hello dear all,
>
>I need to make a simple select query like this:
>select order, SUM(cat1+cat2) from tbl
>when the result of the SUM is =0 i need to change this 0 and display a
>character like '-' .
>
>Is possible to do this? and how?
>
>thanks in advance,
>
>regards
>fabrizio
>


-- 
+------------------------------------------------------------------------+
| Steve Edberg                                      sbedberg@stripped |
| University of California, Davis                          (530)754-9127 |
| Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| "If only life would imitate toys."                                     |
|                  - Ted Raimi, March 2002                               |
|                  - http://www.whoosh.org/issue67/friends67a.html#raimi |
+------------------------------------------------------------------------+
Thread
change displayed text results?fabrizio9 May
  • Re: change displayed text results?Gelu Gogancea9 May
  • Help! Error building 4.0.2 under RH Linux 7.2Vadim P.9 May
  • Re: Help! Error building 4.0.2 under RH Linux 7.2Vadim P.9 May
    • RE: Help! Error building 4.0.2 under RH Linux 7.2crashke10 May
      • Re: Help! Error building 4.0.2 under RH Linux 7.2Vadim P.10 May
      • Re: Help! Error building 4.0.2 under RH Linux 7.2(Trond Eivind Glomsrød)10 May
      • Re: Help! Error building 4.0.2 under RH Linux 7.2Luciano Barcaro11 May
  • Re: change displayed text results?Steve Edberg9 May
RE: change displayed text results?Leif Forer9 May