TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bubai Banerjee
1.6k
163
45.4k
How to insert data from one table to another table after cal
Jan 19 2015 8:22 AM
-- I have a table "
myStoreTable
".which contain 4 columns.
-- I a have another table "
tblFinalTable
", which contain 5 columns.
-- I want to insert data into "
tblFinalTable
" from "tblmyStoreTable".
-- But, not directly inserted,after calculating the "
EmpInterest
", it inserted into
tblFinalTable
table.
-- But i am facing problem while try to insert all the rows in
tblFinalTable
after calculating interest based on "
LOANMTH
" condition.
-- I am a fresher.please help.Thanks in advance.
CREATE TABLE dbo.
tblmyStoreTable
(
CPFNO int NULL,
LOANMTH int NULL,
EMP_OP int NULL,
L_GRANT int NULL
)
INSERT INTO
tblmyStoreTable
(100,0,20000,0)
INSERT INTO
tblmyStoreTable
(200,2,40000,15000)
INSERT INTO
tblmyStoreTable
(300,0,50000,0)
INSERT INTO
tblmyStoreTable
(400,5,70000,20000)
INSERT INTO
tblmyStoreTable
(500,0,100000,0)
CREATE TABLE dbo.
tblFinalTable
(
CPFNO int NULL,
LOANMTH int NULL,
EMP_OP int NULL,
L_GRANT int NULL,
EmpInterest INT
)
declare @InterestRate INT
SET @InterestRate=10
IF(@LOANMTH>0)
BEGIN
INSERT INTO
tblFinalTable
SELECT CPFNO,LOANMTH,(((EMP_OP-L_GRANT)*@InterestRate/100)/12)*((12-(LOANMTH))+1) AS EmpInterest FROM
tblmyStoreTable
END
ELSE
BEGIN
INSERT INTO
tblFinalTable
SELECT CPFNO,LOANMTH,(EMP_OP*@InterestRate/100) as EmpInterest FROM
tblmyStoreTable
END
Reply
Answers (
2
)
SSIS error
How to convert Decimal to Integer Format using sql query