clintnash
asked on
SQL Select - change time values for one row based on value in matching row
I am working on a scheduling page and have hit an interesting issue with trying to manipulate the times. Using the following table as a sample,
The desired results would look as follows.
Please let me know if this makes sense, I have about nine different swipes at this using case but I think I'm going the wrong direction.
As always your help is greatly appreciated.
Thank you.
UID Event Start End
37826 Half Day Breakout-6/6-6/10- 8:30-11:30am 6/6/16 8:30 AM 6/6/16 11:30 AM
37826 General Event 6/6/16 8:30 AM 6/6/16 4:00 PM
37914 Half Day Breakout-6/6-6/10- 8:30-11:30am 6/6/16 1:00 PM 6/6/16 4:00 PM
37914 General Event 6/6/16 8:30 AM 6/6/16 4:00 PM
I need to change the time of the Full Day Event based on the start time of the half day. So if the half day is 8:30 to 11:30, the time start time for the general event should be 1:00 PM and the end time 4:00pm and vise versa if the Start time of the half day is 1:00 to 4:00 then the general event start should be 8:30 and the end 11:30.The desired results would look as follows.
UID Event Start End
37826 Half Day Breakout-6/6-6/10- 8:30-11:30am 6/6/16 8:30 AM 6/6/16 11:30 AM
37826 General Event 6/6/16 1:00 PM 6/6/16 4:00 PM
37914 Half Day Breakout-6/6-6/10- 8:30-11:30am 6/6/16 1:00 PM 6/6/16 4:00 PM
37914 General Event 6/6/16 8:30 AM 6/6/16 11:30 AM
Please let me know if this makes sense, I have about nine different swipes at this using case but I think I'm going the wrong direction.
As always your help is greatly appreciated.
Thank you.
ASKER
Thank you for the response! Unfortunately the General Event actually is one of about 60 events each with specific ID and name. For the purpose of simplicity I change it to 'General Event'. I do have an additional column that I currently don't pull into this query, but I can add groupID to each row as well. The half days have a groupID = 5 and the General Events have a groupID = 6. Any other thoughts on how to do it pulling from the rows?
thanks,
Clint..
thanks,
Clint..
How do you pick an event out of 60 for a certain day? Is it random? Is there any foreign key between the 2 tables?
ASKER
There is a lookup table that connects the user to the event they have registered for.
Instead of us guessing, why not supply:
a. your existing query
b. sample data from EACH table (data per table, include table name and column names)
c. expected result (which we have - thanks)
a "sample" might just be a few rows.
a. your existing query
b. sample data from EACH table (data per table, include table name and column names)
c. expected result (which we have - thanks)
a "sample" might just be a few rows.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That nailed it. Sorry if the question was confusing to some but as always I am thankful for your time.
Open in new window
Result -
Open in new window