You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "McCaffrey, John G." <Jo...@kraft.com> on 2004/04/05 18:06:18 UTC

Is it possible to do a Distinct on just one Column? (non PK)

I need to do a query and retrive a filtered set of data.
Basically I have a composite primary key
item_code
Price_Area_code
price_bracket_cd
effect_date

an item can be in multiple price_areas , and will have historical entries
over time.
to get the current row, I have to check effect_date > current date and
end_effect_date < current date

what I need to do is get a list of item_codes in a given price_area,
regardless of how many brackets entries there are
select a distnct (item_code) where price_area = 1  and effect_date ....

how can I tell ojb which column I want to make distinct?


Could I do a subselect?  
select * from xx_table a where 
	item_code in(select (distinct)  where price_area = 1  and
effect_date ....)

thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Is it possible to do a Distinct on just one Column? (non PK)

Posted by Edson Carlos Ericksson Richter <ed...@mgrinformatica.com.br>.
AFAIK, you will need a ReportQuery.


Richter


McCaffrey, John G. wrote:

>I need to do a query and retrive a filtered set of data.
>Basically I have a composite primary key
>item_code
>Price_Area_code
>price_bracket_cd
>effect_date
>
>an item can be in multiple price_areas , and will have historical entries
>over time.
>to get the current row, I have to check effect_date > current date and
>end_effect_date < current date
>
>what I need to do is get a list of item_codes in a given price_area,
>regardless of how many brackets entries there are
>select a distnct (item_code) where price_area = 1  and effect_date ....
>
>how can I tell ojb which column I want to make distinct?
>
>
>Could I do a subselect?  
>select * from xx_table a where 
>	item_code in(select (distinct)  where price_area = 1  and
>effect_date ....)
>
>thanks!
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org