Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Column

Status
Not open for further replies.

micheals

MIS
Dec 14, 2003
11
MY
I have a database with 3 tables:

Table : TimeTable
Column : TimeTableID

Table : SchoolDay
Column : SchoolDayID , SchoolDayName

Table : TimePeriod
Column : FromTime, ToTime, TimeTableID, SchoolDayID

SchoolDay will have 7 rows, Monday to Sunday. One TimeTable record will have dynamic Time Period records. I want to display the TimeTable in a gridview.

Day | FromTime | ToTime || FromTime | ToTime || ...
Mon |
Tue |
Wed |
Thu |
Fri |
Sat |
Sun |

The number of column should be dynamic based on the TimePeriod. It should display the maximum. Is it possible to write a long SQL to retrieve the data ? If so, how to write the SQL ?
Any idea ? Thanks.













 
The number of column should be dynamic based on the TimePeriod. It should display the maximum. Is it possible to write a long SQL to retrieve the data ?"

No, it isn't.

A SELECT statement does always return a fixed number of columns, as specified in the query.
 
On the other hand, if you transpose your output, you will have a fixed number of columns and can have however many rows of data you wish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top