0

ユーザーがスコアをテキスト入力できる高校のフットボールの試合のスコアを含む小さなデータベースがあります。

不正確または矛盾している可能性のあるスコア レポートを見つける必要があります (前回のスコア投稿以降に減少したスコアはどれか)。

データを考えると、これを行う方法が少し混乱しています。

スコア表

create table FINAL_score
    ( scoreID varchar2(10) primary key,
    gameID varchar2(5) REFERENCES FINAL_game(gameID),
    userID varchar2(5) REFERENCES FINAL_user(userID),
    curtime timestamp,
    qtr number(1),
    hscore number(2) not null,
    ascore number(2) not null);


insert into FINAL_score values ('s001', 'g001', 'u001', '10-DEC-12 02:10:00', 1, 7, 3);
insert into FINAL_score values ('s002', 'g001', 'u002', '10-DEC-12 02:12:00', 1, 7, 3);
insert into FINAL_score values ('s003', 'g001', 'u001', '10-DEC-12 02:15:00', 1, 7, 10);
insert into FINAL_score values ('s004', 'g001', 'u002', '10-DEC-12 02:28:00', 2, 14,13);
insert into FINAL_score values ('s005', 'g001', 'u001', '10-DEC-12 02:30:00', 2, 14,16);
insert into FINAL_score values ('s006', 'g001', 'u001', '10-DEC-12 02:55:00', 3, 14,19);
insert into FINAL_score values ('s007', 'g001', 'u002', '10-DEC-12 02:57:00', 3, 14,16);
insert into FINAL_score values ('s008', 'g001', 'u001', '10-DEC-12 03:15:00', 4, 17,26);
insert into FINAL_score values ('s009', 'g001', 'u002', '10-DEC-12 03:30:00', 4, 20, 29);

^7 番目の挿入ステートメントが矛盾しています。

これまでのところ、私は持っています:

select *
from FINAL_score
order by hscore, ascore, curtime;

それらを注文します。

スコアID 6を削除するだけです

4

1 に答える 1

0

Here is a way that you can get all scores that are less than an earlier score in the game:

select fs.*
from Final_Score fs
where fs.hscore < (select max(fs.hscore) from Final_Score fs2 where fs2.gameid = fs.gameid and and fs2.qtr <= f22.qtr fs2.timestamp < fs.timestamp)

Then, repeat the same thing for ascore.

于 2012-12-13T19:17:26.430 に答える