Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
velvettiger
Posting Yak Master
115 Posts |
Posted - 2013-02-15 : 12:31:28
|
Hi Guys,I would like to output the day that a lecture classes occurs. Now each day is stored in a separate table. Each day is stored in a separate table. The word Monday is stored in a table called SSRMEET_MON_DAY, The word Tuesdays is stored in a table called SSRMEET_TUE_DAY ETC.I am trying to extract all days in one column to then use a where clause to determine which day should be displayed in the report. Therefore, I would like my table to look like:[CODE]DAYSMondayTuesdayWednesdayThursdayInstead of :SSRMEET_MON_DAY SSRMEET_TUES_DAYMonday Tuesday[/codeAnd I don't have the privileges to create temporary tables. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-15 : 13:06:54
|
I didn't quite follow the concept of storing the word Monday in a table named SSRMEET_MON_DAY etc., nonetheless:SELECT code FROM SSRMEET_MON_DAY UNION ALLSELECT code FROM SSRMEET_TUE_DAY UNION ALLSELECT code FROM SSRMEET_WED_DAY UNION ALL....SELECT code FROM SSRMEET_SUN_DAY |
|
|
velvettiger
Posting Yak Master
115 Posts |
Posted - 2013-02-15 : 13:59:07
|
Hi James,If I do the SELECT code as DAYSFROM SSRMEET_MON_DAY UNION ALLSELECT code FROM SSRMEET_TUE_DAY UNION ALLSELECT code FROM SSRMEET_WED_DAY UNION ALL....SELECT code FROM SSRMEET_SUN_DAY Will I be able to do the followingwhere Days = 'Monday' |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-15 : 14:21:29
|
yep you'll be able to do itSELECT *FROM(SELECT code as DAYSFROM SSRMEET_MON_DAY UNION ALLSELECT code FROM SSRMEET_TUE_DAY UNION ALLSELECT code FROM SSRMEET_WED_DAY UNION ALL....SELECT code FROM SSRMEET_SUN_DAY)tWHERE DAYS ='Monday' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|