GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 137 of 171    Print  
in a table a column is having value like 'Steven Kovy'. without using concat() function and concatenate operator "||" how to display like 'Kovy Steven'

  
Total Answers and Comments: 2 Last Update: June 25, 2008     Asked by: us.arvindpriya 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 23, 2007 07:38:12   #1  
Enrique        

RE: in a table a column is having value like 'Steven K...
/*
* In a table a column is having value like 'Steven Kovy'. without using concat() function and
* concatenate operator "||" how to display like 'Kovy Steven'
*/
SELECT STUFF(STUFF(FirstName 1 CHARINDEX(' ' FirstName) - 1
SUBSTRING(FirstName CHARINDEX(' ' FirstName) + 1 LEN(FirstName)))
LEN(FirstName) - CHARINDEX(' ' FirstName) + 2
LEN(FirstName) - CHARINDEX(' ' FirstName)
SUBSTRING(FirstName 0 CHARINDEX(' ' FirstName))) As ModifiedString
FROM Emp
WHERE FirstName LIKE ' '

 
Is this answer useful? Yes | No
June 24, 2008 11:25:17   #2  
rahul.katke Member Since: December 2007   Contribution: 3    

RE: in a table a column is having value like 'Steven Kovy'. without using concat() function and concatenate operator "||" how to display like 'Kovy Steven'

Assuming you had a table called s_emp2 which is nothing but the emp table from scott schema...

The qry below should serve the purpose.

select rpad(rpad(substr(ename instr(ename ' ')+1) length(substr(ename instr(ename ' ')+1))+1 ' ') length(ename) substr(ename 1 instr(ename ' ')-1)) reversed from s_emp2;

Again some assumptions:

1. there is only 1 space between Steven and Kovy mentioned above.
2. and the space mentioned in point 1 above is the only space in the string.

Log:

SQL> select ename rpad(rpad(substr(ename instr(ename ' ')+1) length(substr(ename instr(ename ' ')+1))+1 ' ') length(ename) substr(ename 1 instr(ename ' ')-1)) reversed from s_emp2;

ENAME REVERSED
---------- ------------------------------
55 SMITH SMITH 55
ALLEN
WARD BOY BOY WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS

ENAME REVERSED
---------- ------------------------------
JAMES
FORD
MILLER
RAHUL K K RAHUL

15 rows selected.

Elapsed: 00:00:00.90
SQL>

Similar such thing could also be achieved using LPAD.

Hope that helps!

- Rahul Katke.


 
Is this answer useful? Yes | No

 Related Questions

Self join-Its a join foreign key of a table references the same table. Outer Join--Its a join condition used where One can query all the rows of one of the tables in the join condition even though they 
Latest Answer : Please let me know various joins available and description for every joinRegards,sireesha ...

Rename is a permanent name given to a table or column whereas Alias is a temporary name given to a table or column which do not exist once the SQL statement is executed. 
Latest Answer : Rename means give the new name to existed objects alise is use to refrence to objects ...

A view is stored procedure based on one or more tables, it’s a virtual table. 
Latest Answer : View View is logical table based on one are more table join and named as viewname View is not stored in database View is used to perform complex query, View Object, View support, LOB, varray, Nested Tables Should have CREATE ...

A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically 
Latest Answer : Primay Key                     Unique key-----------                  ...

delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name); ordelete duplicate_values_field_name dv from table_name ta where rowid  
Latest Answer : Delete table_name t1where rowid>(select rowid from table_name t2)and t1.column1=t2.column1 ...

'' Should be used before '%'. 
Latest Answer : select * from emp where instr('ename','%')!=0 ...

HAVING clause is used when you want to specify a condition for a group function and it is written after GROUP BY clause. The WHERE clause is used when you want to specify a condition for columns, single 
Latest Answer : when query is based on condition we use where clause & there is no any aggregate functionwhen query is base on contion & aggregate function has to be use then we can usehaving clause. ...

SELECT * FROM empWhere emp_no+' '=12345;i.e you have to concatenate the column name with space within codes in the where condition.SELECT /*+ FULL(a) */ ename, emp_no from empwhere emp_no=1234;i.e 
Latest Answer : One way is to diable the index on the column using syntaxAlter index indexname on table_name disable.One way is to apply  /*+no_index */ hint to the query For eg: select ename /*+no_index */from empwhere ename ='smith' ...

It is a column that is not an actual column in the table.eg USER, UID, SYSDATE, ROWNUM, ROWID, NULL, AND LEVEL. 
Latest Answer : Pseudo columns is not actula column in the table. it behaves like table columnwe can retivesv values of pseduo column but can not insert,update or delete value in that.has two data type 1. rowid  2. urowidrow id uniqely identify row in databaseEXM ...

Suppose a customer table is having different columns like customer no, payments.What will be the query to select top three max payments?
SELECT customer_no, payments from customer C1WHERE 3 


 Sponsored Links

 
Related Articles

Querying Data with Oracle XQuery

Querying Data with Oracle XQuery Starting with Oracle Database 10g Release 2 you can take advantage of a full featured native XQuery engine integrated with the database With Oracle XQuery you can accomplish various tasks involved in developing PHP Oracle XML applications operating on any kind of dat
 

Using Oracle XML DB Repository

Using Oracle XML DB Repository Another variation on accessing and manipulating XML content stored in Oracle database is provided by Oracle XML DB repository which is an essential component of Oracle XML DB mosgoogle NOTE Oracle XML DB repository also known as XML repository is a hierarchically organ
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

XML Processing in PHP and Oracle Applications

Processing XML in PHP Oracle Applications As mentioned there are two alternatives when it comes to performing XML processing in your PHP Oracle application You can perform any required XML processing using either PHP s XML extensions or PEAR XML packages or Oracle s XML features mosgoogle In the fol
 

PHP Oracle Web Development

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax is a good starting b
 

ODP.NET - Populating a Dataset with a Single Data Table

ODP NET Populating a Dataset with a Single Data Table A dataset is simply a group of data tables These data tables can be identified with their own unique names within a dataset You can also add relations between data tables available in a dataset mosgoogle The following code gives you the details o
 

Getting Started with Oracle and ODP.NET

ODP NET Developer’ s Guide by Jagadish Chatarji Pulakhandam Sunitha Paruchuri A practical guide for developers working with the Oracle Data Provider for NET and the Oracle Developer Tools for Visual Studio 2005 Application development with ODP NET Dealing with XML DB using ODP NET Oracle
 

PHP Oracle Web Development Review

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books The author is also an expert in open source technologies and SOA Service Oriented Architecture But besides
 

jQuery Table Row Finished Code

jQuery Table Row Finished Code The Finished Code Our second example page has demonstrated table row striping highlighting tooltips collapsing expanding and filtering Taken together the JavaScript code for this page is mosgoogle geshibot lang php" document ready function var highlighted
 

jQuery Expanding and Collapsing Table Rows

jQuery Expanding and Collapsing Table Rows The expanding and collapsing behavior added earlier also conflicts with our filters If a section is collapsed and a new filter is chosen then the matching items are displayed even if in the collapsed section Conversely if the table is filtered and a section
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape