Сортировка

Eyxeniy
Дата: 17.12.2012 20:07:31
Как можно написать запрос чтобы отсортировать
select
 lag(null,1,x) over (partition by x order by null) xx
,lag(null,1,y) over (partition by x,y order by null) yy
,lag(null,1,z) over (partition by x,y,z order by null) zz
from (
select 'abс' x, 'bg' y, 'fg' z
 from dual
 union all
 select 'rr' x, 'po' y, 'en' z
 from dual
 union all
 select 'abс' x, 'bg' y, 'fg' z
 
 from dual
 
 ) 
order by x,y,z;

Запрос нам выдает 2 строчки.
Мне надо чтобы если поменять строку 3 т.е. написать select fg , 'bg' , 'abс'
То, также вывело 2 строчки.
Leonid Kudryavtsev
Дата: 17.12.2012 20:13:37
Eyxeniy
Запрос нам выдает 2 строчки

На моем Oracle выдает 3 ))). Только одна строчка результата целиком из пустых строк состоит
orawish
Дата: 17.12.2012 20:44:12
Eyxeniy,

курить вообще вредно, а уж (извините) жопой - и подавно.
хотите сортировки - используйте order by
Eyxeniy
Дата: 17.12.2012 22:59:12
orawish,
может и куришь ты )))))

XX YY ZZ
--- -- --
abс bg fg

rr po en
orawish
Дата: 17.12.2012 23:55:13
Eyxeniy
orawish,
может и куришь ты )))))

XX YY ZZ
--- -- --
abс bg fg

rr po en

дык, не обо мне речь, а о том, что галиматью, которую вы тут публикуете иначе не классифицировать.
учите матчасть, хватит позориться
Eyxeniy
Дата: 18.12.2012 00:22:57
orawish,

надо с чего то начинать ...
qwerty24
Дата: 18.12.2012 10:21:07
Eyxeniy,

Оно?

select
 lag(null,1,x) over (partition by least(x,y,z),greatest(x,y,z), decode(x,least(x,y,z),decode(y,greatest(x,y,z),z,y),greatest(x,y,z),decode(y,least(x,y,z),z,y),x) order by x,y,z) xx
,lag(null,1,y) over (partition by least(x,y,z),greatest(x,y,z), decode(x,least(x,y,z),decode(y,greatest(x,y,z),z,y),greatest(x,y,z),decode(y,least(x,y,z),z,y),x) order by x,y,z) yy
,lag(null,1,z) over (partition by least(x,y,z),greatest(x,y,z), decode(x,least(x,y,z),decode(y,greatest(x,y,z),z,y),greatest(x,y,z),decode(y,least(x,y,z),z,y),x) order by x,y,z) zz
from (
select 'abс' x, 'bg' y, 'fg' z
 from dual
 union all
 select 'rr' x, 'po' y, 'en' z
 from dual
 union all
 select 'fg' x, 'bg' y, 'abс' z
 from dual
 
 ) 
order by x,y,z;
Сергей Арсеньев
Дата: 18.12.2012 11:05:07
Eyxeniy,

Прежде чем на кого-то наезжать посмотрите внимательно сколько строк возвращается, а то может вы какую-то просто не видите. :)
Eyxeniy
Дата: 18.12.2012 20:17:36
qwerty24,
Спасибо дружище, есть в чем разбираться)
Еще раз спасибо.
Eyxeniy
Дата: 24.12.2012 22:16:58
Ребята, как можно решить эту ..., не используя partition by ???
select
 lag(null,1,x) over (partition by least(x,y,z),greatest(x,y,z), decode(x,least(x,y,z),decode(y,greatest(x,y,z),z,y),greatest(x,y,z),decode(y,least(x,y,z),z,y),x) order by x,y,z) xx
,lag(null,1,y) over (partition by least(x,y,z),greatest(x,y,z), decode(x,least(x,y,z),decode(y,greatest(x,y,z),z,y),greatest(x,y,z),decode(y,least(x,y,z),z,y),x) order by x,y,z) yy
,lag(null,1,z) over (partition by least(x,y,z),greatest(x,y,z), decode(x,least(x,y,z),decode(y,greatest(x,y,z),z,y),greatest(x,y,z),decode(y,least(x,y,z),z,y),x) order by x,y,z) zz
from (
select 'abс' x, 'bg' y, 'fg' z
 from dual
 union all
 select 'rr' x, 'po' y, 'en' z
 from dual
 union all
 select 'fg' x, 'bg' y, 'abс' z
 from dual
 
 ) 
order by x,y,z;

Буду рад любым направлениям)