CASE Objects

How do I create a CASE Object so that the name rather than the statement is in the GROUP BY clause?

Example:

SELECT
CASE (…) name_of_case_object
sum(units)
FROM table
GROUP BY
name_of_case_object

Right now it is doing the following:
SELECT
CASE (…)
sum(units)
FROM table
GROUP BY
CASE (…)

Thanks!!

Kathy Vazquez


Listserv Archives (BOB member since 2002-06-25)

In a message dated 00-03-08 10:09:15 EST, you write:

How do I create a CASE Object so that the name rather than the statement is
in the GROUP BY clause?

It depends on whether you database allows that or not. In most cases, the Group By must reflect exactly the same as the select clause. For example:

select first_name + last_name full_name, count(*) from customer
group by first_name + last_name

The group by must include the exact expression so that it knows how to “group” the data. It can’t simply refer to “full_name” as that has no meaning to the database. I suspect that you are in the same situation.

You should get the correct answer. Is there any reason you are looking for the case name instead of the expression?

Regards,
Dave Rathbun
Integra Solutions
www.islink.com


Listserv Archives (BOB member since 2002-06-25)

Kathy’s Question:


Listserv Archives (BOB member since 2002-06-25)