i have a table with the follwoing structure
id g_id name status
---------------------------------------
1 111 item1 1
2 111 item2 1
3 111 item3 1
6 113 item1 -1
7 113 item2 1
8 113 item3 1
9 114 item1 1
10 114 item2 2
status can contains values ,
success : 1
Failed : -1
In progress : 2
Need the following output
GroupID Status
------------------
111 Success
113 Failed
114 In-Progress
If one in the group is -1, result should be Failed and if all is 1 then it should be Success. Also if some are 1 and rest is 2 result should be In Progress.
What is the best way i can select the above results?
SQL FIDDLE EXAMPLE