Domanda di colloquio di Capgemini

Sql query: There is a table, called alphabet, a column in it as alpha, there are 6 rows in that column as a,b,c,d,e,f. I want to display feabcd in output

Risposte di colloquio

Anonimo

27 ago 2018

I tried using order by and row_number function.

11

Anonimo

29 mag 2019

Select alpha from( select t*,row_number() over(order by alpha desc) as r from alphabet) as t where r beteen 1 and 2 UNION ALL Select alpha from( select t*,row_number() over(order by alpha ) as r from alphabet) as t where r beteen 1 and 2

1

Anonimo

30 mag 2019

select alpha, case when alpha='a' then 'f' when alpha='b' then 'e' when alpha='c' then 'a' when alpha='d' then 'b' when alpha='e' then 'c' when alpha='f' then 'd' end new_seq from alphabet;

4

Anonimo

10 ott 2019

Use analytical function

4

Anonimo

14 nov 2019

select * from alpha order by case when id='f' then 'f' when id='e' then 'e' when id='a' then 'a' end desc

Anonimo

5 set 2019

Select * from alphabet order by --alpha desc case when alpha in ('e','f') then NULL Else alpha