Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SQL Challenge

popovitsjApr 3 2013 — edited Apr 4 2013
My teacher presented us with the following challenge.

There is a table that has 3 columns:
- Team
- Date of the match
- Won or Lost

Write an SQL Query (no PL/SQL), that returns the team or teams that has/have the highest winning streak and the number of consecutive wins.

Only 'regular' SQL is allowed, so no Oracle-specific functions.

I have already (I think) solved this, but I was wondering what solutions you guys would come up with.

I'll post my solution later.

Below I've provided some sample DDL.
CREATE TABLE Games(Team VARCHAR2(10), MatchDate DATE, WL VARCHAR2(1));
INSERT INTO Games VALUES ('TeamA','1-JAN-2012','W');
INSERT INTO Games VALUES ('TeamA','2-JAN-2012','W');
INSERT INTO Games VALUES ('TeamA','3-JAN-2012','W');
INSERT INTO Games VALUES ('TeamB','4-JAN-2012','W');
INSERT INTO Games VALUES ('TeamB','5-JAN-2012','W');
INSERT INTO Games VALUES ('TeamB','6-JAN-2012','W');
INSERT INTO Games VALUES ('TeamA','7-JAN-2012','L');
INSERT INTO Games VALUES ('TeamA','8-JAN-2012','W');
INSERT INTO Games VALUES ('TeamA','10-JAN-2012','W');
Edited by: popovitsj on Apr 3, 2013 7:50 AM

Edited by: popovitsj on Apr 3, 2013 8:21 AM

Edited by: popovitsj on 3-apr-2013 12:23

Edited by: popovitsj on 3-apr-2013 12:36
This post has been answered by Stew Ashton on Apr 3 2013
Jump to Answer

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 2 2013
Added on Apr 3 2013
22 comments
3,239 views