I want a query which will return a combination of characters and number
Example:
Table name – emp
Columns required – fname,lname,code
If fname=abc and lname=pqr and the row is very first of the table then result should be code = ap001.
For next row it should be like this:
Fname = efg, lname = rst
Code = er002 and likewise.
I know that we can use substr to retrieve first letter of a colume but I don’t know how to use it to do with two columns and how to concatenate.
OK. You know you can use
substrfunction. Now, to concatenate you will need a concatenation operator||. To get the number of row retrieved by your query, you need therownumpseudocolumn. Perhaps you will also need to useto_charfunction to format the number. About all those functions and operators you can read in SQL reference. Anyway I think you need something like this (I didn’t check it):