Home » SQL & PL/SQL » SQL & PL/SQL » Case statement for multiple options
Case statement for multiple options [message #646745] Thu, 07 January 2016 14:16 Go to next message
blyzz
Messages: 10
Registered: October 2015
Junior Member
I have a table of tests where I have data in the format:
English 8:30 9:00 9:30
Reading start stop
Writing start continue stop
Compre start stop



I need to get start and stop time for all sections as when the value for each section is stop then the test is complete
So the start time for the test is 8:30 and finish time is 9:30

I was thinking something like this:


Case when subject=english
when section=reading and value =start then time as start_Time
when section=reading and value =stop then time as end_Time

when section=writing and value =start then time as start_Time
when section=writing and value =stop then time as end_Time


when section=comprehension and value =start then time as start_Time
when section=comprehension and value =stop then time as end_Time


How can I do that?

Thanks,
blyzz
Re: Case statement for multiple options [message #646746 is a reply to message #646745] Thu, 07 January 2016 14:31 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:
OraFAQ Forum Guide
How to use {code} tags and make your code easier to read
Re: Case statement for multiple options [message #646747 is a reply to message #646745] Thu, 07 January 2016 14:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
I have data in the format:


What format?

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals.

In the end, feedback to your previous topics BEFORE posting a new question.

Re: Case statement for multiple options [message #646755 is a reply to message #646747] Fri, 08 January 2016 02:54 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Any given call to a CASE statement can only return the value for one column per row. If you want multiple columns you need multiple case statements.
Previous Topic: Joining on optional TABLE OF NUMBER parameters
Next Topic: Generate unique combinations
Goto Forum:
  


Current Time: Fri Apr 19 21:20:28 CDT 2024