Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have table Student with these columns names
student_code , stud_act_id , fee , discount_rate
A 52165 200 60
A 54902 300 50
A 54167 100 30
B 54165 60
B 54167 30
B 54902 50

I want query to display the values like:
Here Discount Fee value takes from the student_code fee and discount_rate .
Discount Fee: (200-(60+(60*10)/100)).
Discount Fee: (300-(50+(50*10)/100)).
Discount Fee: (100-(30+(30*10)/100)).
The discount Fee value will taking form the student_code of A of discount_rate and fee and result append to the Student_code B
The out put should like this:

student_code , stud_act_id , fee , discount_rate
A 52165 200 60
A 54902 300 50
A 54167 100 30
B(Discount Fee:134) 52165 60
B(Discount Fee:245) 54902 50
B(Discount Fee:67) 54167 30

Please give me solution ...

Thanks,
Posted

1 solution

Firstly, x + (x * 10)/100 = x * 1.1 - pedantic I'm sure, but easier to read IMHO

Your output doesn't really makes any sense, as you are including different values (one lot from A and the other from B) in the columns - and one set includes 4 columns, the other just 3 columns...

Are A and B the table names? you have a heading of Student Code, but there is a match between the Ids in each group.

My best guess at what you are after is:

Select fee - (discount_rate * 1.1), stud_act_id, discount rate from B 


which will give you
134    52165    60
245    54902    50
 67    54167    30


If you really also need the stuff from the other table then you can get away with

Select * from A



I'm guessing that a) this isn't what you're after and b) this is homework - so you probably need to a) give clearer information and b) at least try something yourself and ask for help, rather than just asking someone to do it for you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900