Skip to content

Instantly share code, notes, and snippets.

@axiak
Created December 22, 2011 04:25
Show Gist options
  • Save axiak/1508915 to your computer and use it in GitHub Desktop.
Save axiak/1508915 to your computer and use it in GitHub Desktop.
select distinct
<include refid="t_fact_columns_fragment" />
from
t_fact fct,
t_location_fact locf,
t_user_location uloc,
t_location loc
where
fct.fact_pk = locf.fact_pk and
loc.location_id = locf.location_id and
loc.location_active = 'Y' and
uloc.location_id(+) = locf.location_id and
uloc.user_pk(+) = ${user_pk}
group by
<include refid="t_fact_columns_fragment" />
having
-- DANGER - This line is slightly subtle. Do not change unless
-- you understand what it is trying to do.
min(decode(uloc.active_flag, 'Y', 1, 0)) = 1
order by
fct.short_fact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment