View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 08:34 AM
Gordon Burditt
 
Posts: n/a
Default Re: conditional group by?

>Say I have a table like this:
>
>customer_number | name
>
>I'd like to do a group by the customer_number unless the
>customer_number is negative, at which point, I'd like to group by name.
>
>Unfortunately, I'm not really sure how to do that. Any ideas?


Write an expression that returns the customer_number unless the
customer_number is negative, in which case, it returns the name.
Hint: if()

Now group by that.
Reply With Quote