vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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? |
| |||
| >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. |
| ||||
| yawnmoth wrote: > 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? Either like Gordon said or UNION 2 queries, one of which deals with the negative customer numbers and the other which deals with the rest |