how to display row value instead of column values

Posted by Klbaiju under Sql Server on 7/4/2013 | Points: 10 | Views : 894 | Status : [Member] | Replies : 1

I have a travel related application.and tables Busmaster and Busdetails.

Busmaster contains busid,model,busname

Busdetails contains busid,tourdate,bookdate,fare,status. and there are 4 buses.

in every month 4 buses will be booked for some days.

my requirement is if i select a month and year from dropdown boxes i want to display details of the month

following is sample output like this

date 100 101 102 103

2013-08-01 booked available booked booked

2013-08-02 available booked available available


2013-08-31 availabble booked available available

here 100,101,102,103 are busid's how it is possible i trid this using pivot but not working

idea is if tourdate in busdetails matches with particular date the display booked otherwise available.

above data is sample of 2013 august.

any body know help me




Posted by: Ssj_Kumar on: 7/10/2013 [Member] Starter | Points: 25

This can be done with SQL Pivot, using pivot you can display row value as column value.
Go for a dynamic pivot, and your input should be month and year

Jayakumar Selvakani

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response