Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all,

I have values in sql table like

RollNumber RoomNumber  RoomType    Status
---------------------------------------------
A101         1         Single      Booked
---------------------------------------------
A102         2         Single      Booked
---------------------------------------------
A103,A104    3         TwoSeater   Booked
---------------------------------------------
A105         4         TwoSeater   Available
---------------------------------------------
A106,A107    3         FourSeater  Available
---------------------------------------------
A105         4         FourSeater  Available
---------------------------------------------


Now i need get count of rollnumber where roomtype= twoseater.
Then if already roll numbers (A103,A104) filled ,then status will show Booked.
Now if roll number (A105) filled but i need to insert another one rollnumber for two seater(RoomType), that status will show available.

these above operation i need to do in asp.net using c#.

Can anyone help me.

Sorry for average english

Thanks in advance............

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 20-Jun-12 20:08pm
v2
Comments
bhagirathimfs 21-Jun-12 2:16am    
Is status column is already there in the table??

1 solution

To return the number of rooms in the class "TwoSeater":
SQL
SELECT COUNT(RollNumber) FROM myTable WHERE RoomType='TwoSeater'


Personally, I would not store the room class as a description, but store an Integer number of "Seats" instead. That way, you can do math to achieve your result, by returning the top result where type is available, and seats >= number-of-seats-required, ordered by "Seats" in ascending order.
 
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