views:

9

answers:

0

I have two tables named IN_Heads, Emp.

IN_Heads has one column named Head_Desc with following values

Head_Desc

..................

Basic

DA

HRA

Emp table has following structure:

Emp_No :: BASIC :: DA :: HRA :: LTA :: Canteen

20 :: 4330 :: 340 :: 2763 :: 300 :: 0

21 :: 4000 :: 600 :: 2133 :: 500 :: 30

27 :: 7320 :: 100 :: 3163 :: 600 :: 60

23 :: 5690 :: 900 :: 4663 :: 100 :: 70

25 :: 8355 :: 150 :: 1563 :: 200 :: 0

Now my problem is I want to get from EMP table Addition of only those columns' values which are present under Head_Desc of table IN_Heads. (i.e. (Basic + DA + HRA) only, excluding LTA & CANTEEN as they dont appear in IN_Heads table). Values of Head_Desc may vary time to time.

I'm using stored procedures and user defined functions. I need to write a function for the above to get a single float value for given employee, say emp_no 21.

Any suggestion. Its urgent. Please.