Click here to Skip to main content
16,019,983 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a table in db which contains roomtype and roomrate columns.Based on the checkin and checkout dates the relevant data would be displayed in a grid view on a page .
Now from jan 1st-march 31st ,roomtype1 rate would be 250
from april 1st-july 31st,roomrate1 rate would be 350

if user selects checkin date as march 29th and checkout date as april 2nd then room rate has to be calculated as following

march 29th=250
march 30th=250
march 31st=250
april 1st=350
april 2nd=350
total=1450
how to perform this calculation in a stored procedure??
Posted
Comments
[no name] 28-Jun-11 3:46am    
post what you have done so far, let us take a look and correct the mistake.
And also post table structure for roomtype and roomrate.
[no name] 28-Jun-11 4:45am    
put your table structure and also I like to know are you storing rates in some table and is there any link present in both the table.

1 solution

The sql construct you will wish to incorporate for this is the CASE( Transact-SQL)[^] statement.
 
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