Adding a prefix to a value [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a table called EMP_SAL which has 2 columns EID number(7), SAL number(4).
EID column values: 100,101,102
SAL column values: 1000,2000,3000
I want to update the table so that the values in the EID column are displayed like ENO.100,ENO.101,ENO.102 instead of showing 100,101,102.

The answer is No. You cannot put characters in a number column. You should redesign your table and make the EID column varchar2 in order to put characters there.
The update would be simple:
Update EMP set EID='ENO.'||EID;

Related

How to update employee email address from employee table (need to change just domain name of all employees) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have employee table with 100 records and have email-id column in it.
but suppose now company has changed domain of email id example:- earlier it was abc#example.com
now it has changed to abc#gmail.com
so how to update same in employees table only have to change domain name from email id of employee table
Please suggest some way in oracle plsql or sql
You can use REPLACE as follows:
UPDATE EMPLOYEE
SET EMAIL = REPLACE(EMAIL,'#example.com','#gmail.com')

POSTGRESQL: Insert Data from another table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
In above table customer ids are listed what I want to do is to get those ids from this table,
create another table named PROMOTION CLASSES where PREMIUM, PLUS AND NORMAL are in columns and put first 100 ids under PREMIUM COLUMN and soon.
Please help.
This creates you table with classification
CREATE TABLE promotion_classes as
SELECT customer_id,
case when customer_id < 100 then
'PREMIUM'
else
'NORMAL'
END as CLASSES
FROM CUSTOMER_TBL

Remove rows with duplicate value for a column in SQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
From the above table, I want to remove the rows that have the duplicate CODE column. Out of the duplicate rows, the row with the smallest ID_CHECK should be retained.
Output:
If I understand correctly, this should be your SQL query:
Select Names, Code, ID_CHECK
FROM
(
Select Names, Code, ID_CHECK,
ROW_NUMBER() OVER(Partition by Name,Code Order By ID_CHECK) as rnk
FROM table
)tmp
WHERE tmp.rnk=1;
Let me know if this works.

Divide all values but one in sql table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
i got this table, and i want to divide all the values on one of the columns except one.
I havent wrote any code about it just looking for an explanation on how to do it, if anyone could help out would appreciate.
In order to modify the content of one column in all rows except one, you can use the following query:
UPDATE tablename SET columName = columnName / 42 WHERE rowId !=42;
WHERE contains the condition that has to evaluate to true, in order for the update to take effect. My example modifies all rows except for those whose rowId column contains the value 42.

Insert into a backup table based on date [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My table in Oracle 11g has 6 fields. I also have a backup table also with no values. The original table has 2 date values. I need to insert into the backup table from the original table the orders having an order-date 5 months back as of today.
The table has a field names ORDER-DATE and has records entered inside.
insert into backup_table
select * from original_table
where order-data > add_months(sysdate,-5);