Sei sulla pagina 1di 6

PL/SQL Challenge - Take Quiz var apex_img_dir = "/i/",

htmldb_Img_Dir = apex_img_dir; #count-down-timer { border-style: none;


height:auto; padding:0 4px 4px; width:auto; border: 1px solid #ccc;
font-size:7pt; } span.obfuscate { position: absolute; overflow: hidden; clip:
rect(0 0 0 0); height: 1px; width: 1px; margin: -1px; padding: 0; border: 0; }
<!-- htmldb_delete_message='Would you like to perform this delete action?';
//--> function submitMe(p_eventId, p_quizId) { // alert('Submitting the page
with values: ' + p_eventId + ' and ' + p_quizId); apex.submit({
request:"RECORD", set:{"P23_NEXT_COMP_EVENT_ID": p_eventId, "P23_NEXT_QUIZ_ID":
p_quizId }}); } div.copyright { margin-top: 10px; margin-right: 5px; }
#profile_summary .button-alt1 { padding-bottom:5px; width:150px; }

VF=>user ID=>40237 Welcome, USER40237 (1049) Submit Quiz


Feedback FAQ Blog Invite Friends Account Home Logout
1,058,534 quizzes played | 2,736 active players

Library
Practice
Tests
Rankings
Players
Polls
Messages (NEW)
Favorites

<h1>Sorry, this Web site requires JavaScript to function properly.</h1>


<h1>Please enable JavaScript in your browser.</h1>

SQL Deja Vu: 8 Apr - 14 Apr 2017


Time Remaining:
3d 00:56:35

Review Assumptions Review Instructions

Question 1 of 1

Assume Running:Oracle Database 10g


Author:Kim Berg Hansen

Open Question In New Window

We log the price of gasoline every day in this


table:
create table plch_gas_price_log (
logged_date date unique
, logged_price number not null
)
/
insert into plch_gas_price_log values (date '2014-09-01', 7.50)
/
insert into plch_gas_price_log values (date '2014-09-02', 7.61)
/
insert into plch_gas_price_log values (date '2014-09-03', 7.72)
/
insert into plch_gas_price_log values (date '2014-09-04', 7.89)
/
insert into plch_gas_price_log values (date '2014-09-05', 7.89)
/
insert into plch_gas_price_log values (date '2014-09-06', 7.83)
/
insert into plch_gas_price_log values (date '2014-09-07', 7.55)
/
insert into plch_gas_price_log values (date '2014-09-08', 7.55)
/
insert into plch_gas_price_log values (date '2014-09-09', 7.72)
/
insert into plch_gas_price_log values (date '2014-09-10', 7.89)
/
insert into plch_gas_price_log values (date '2014-09-11', 7.61)
/
insert into plch_gas_price_log values (date '2014-09-12', 7.61)
/
insert into plch_gas_price_log values (date '2014-09-13', 7.61)
/
insert into plch_gas_price_log values (date '2014-09-14', 7.72)
/
commit
/
(Prices are typical Danish gasoline prices, just
converted from Danish Kroner per liter to US
Dollars per gallon.)
Our analytical department wishes to assign a
consecutive group id to the logged prices in such
a manner, that when the same price is repeated on
consecutive days, the same group id should be
used.
Which of the choices contain a query that assigns
such a group id returning this desired output:
LOGGED_DA LOGGED_PRICE LOGGED_GROUP_ID
--------- ------------ ---------------
01-SEP-14 7.5 1
02-SEP-14 7.61 2
03-SEP-14 7.72 3
04-SEP-14 7.89 4
05-SEP-14 7.89 4
06-SEP-14 7.83 5
07-SEP-14 7.55 6
08-SEP-14 7.55 6
09-SEP-14 7.72 7
10-SEP-14 7.89 8
11-SEP-14 7.61 9
12-SEP-14 7.61 9
13-SEP-14 7.61 9
14-SEP-14 7.72 10
As september 4th and 5th have same price, they get
same group id, but while september 10th has the
same price too, it is not consecutively following
the other two dates, so it gets it's own group id.

Open Question In New Window

Which Are Correct?


Check the box next to any choice you believe is a correct
answer to the question. If you believe that none of the
choices are correct, check the box at the bottom of the page
next to "None of the choices are correct." You must check at
least one box before your answer can be saved.

Number of Choices: 6

Choice #1
select logged_date
, logged_price
, dense_rank() over (
order by period_group
) logged_group_id
from (
select logged_date
, logged_price
, last_value(period_start ignore nulls) over (
order by logged_date
rows between unbounded preceding and current row
) period_group
from (
select logged_date
, logged_price
, case lag(logged_price) over (order by logged_date)
when logged_price then null
else logged_date
end period_start
from plch_gas_price_log
)
)
order by logged_date
/

Choice #2
select logged_date
, logged_price
, sum(period_start) over (
order by logged_date
rows between unbounded preceding and current row
) logged_group_id
from (
select logged_date
, logged_price
, case lag(logged_price) over (order by logged_date)
when logged_price then 0
else 1
end period_start
from plch_gas_price_log
)
order by logged_date
/

Choice #3
select logged_date
, logged_price
, (
select count(*)
from plch_gas_price_log g2
join plch_gas_price_log g3
on g3.logged_date = g2.logged_date - 1
where g3.logged_price != g2.logged_price
and g2.logged_date <= g1.logged_date
) + 1 logged_group_id
from plch_gas_price_log g1
order by logged_date
/
Choice #4
select logged_date
, logged_price
, row_number() over (
order by logged_date
) - sum(identical) over (
order by logged_date
rows between unbounded preceding and current row
) logged_group_id
from (
select logged_date
, logged_price
, decode(
lag(logged_price) over (order by logged_date) - logged_price
, 0, 1
, 0
) identical
from plch_gas_price_log
)
order by logged_date
/

Choice #5
select logged_date
, logged_price
, dense_rank() over (
order by logged_price
) logged_group_id
from plch_gas_price_log
order by logged_date
/

Choice #6
select logged_date
, logged_price
, row_number() over (
partition by logged_price
order by logged_price
) logged_group_id
from plch_gas_price_log
order by logged_date
/

No choice is correct.

Submit
var s_pageName="plsqlchallenge:en-us:"; if
(typeof(document.title)!= "undefined") {var s_pageName = s_pageName
+ document.title.trim()};

About Oracle | | Terms of Use | Your Privacy Rights | Copyright 2010-2017,


Oracle Corporation
$('#count-down-timer').countdown({ until: 262746, compact: true, onTick:
function(timeRemaining) { var years = timeRemaining[1] var months =
timeRemaining[2]; var days = timeRemaining[3]; var hours = timeRemaining[4]; var
minutes = timeRemaining[5]; var seconds = timeRemaining[6]; }, onExpiry:
function() { doSubmit('TIME_EXPIRED'); } });
$('input[name="f01"]').click(function() { if ($('#P23_ONLY_ONE_CHOICE').val()
== 'Y') { $('input[name="f01"]').attr('checked', false); $(this).attr('checked',
true); } }); body { -webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none; -ms-user-select: none;
-o-user-select: none; user-select: none; } try { var pageTracker =
_gat._getTracker("UA-15210760-1"); pageTracker._trackPageview(); } catch(err) {}
apex.da.initDaEventList = function(){ apex.da.gEventList = [
{"triggeringElementType":"ITEM","triggeringElement":"P23_NONE_CORRECT","conditi
onElement":"P23_NONE_CORRECT","triggeringConditionType":"NOT_NULL","bindType":"b
ind","bindEventType":"change","anyActionsFireOnInit":false,actionList:[{"eventRe
sult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunct
ion:functione
(){ $('input[name="f01"]').attr('checked', false);
},"action":"NATIVE_JAVASCRIPT_CODE"}]},
{"conditionElement":"P23_NONE_CORRECT","bindEventType":"ready","anyActionsFireO
nInit":false,actionList:[{"eventResult":true,"executeOnPageInit":false,"stopExec
utionOnError":true,"affectedElementsType":"REGION","affectedRegionId":"R80970736
92055107119",javascriptFunction:com_oracle_apex_timer.init,"attribute01":"add","
attribute02":"TTQ_TIMER","attribute03":"1000","attribute04":"infinite","action":
"PLUGIN_COM.ORACLE.APEX.TIMER"}]},
{"triggeringElementType":"REGION","triggeringRegionId":"R8097073692055107119","
conditionElement":"P23_NONE_CORRECT","bindType":"bind","bindEventType":"timer_ex
pired.COM_ORACLE_APEX_TIMER","anyActionsFireOnInit":false,actionList:[{"eventRes
ult":true,"executeOnPageInit":false,"stopExecutionOnError":true,"affectedElement
sType":"REGION","affectedRegionId":"R8097073692055107119",javascriptFunction:ape
x.da.refresh,"action":"NATIVE_REFRESH"}]}];
} apex.jQuery( document ).ready( function() {
(function(){apex.widget.report.init("R8097072303007107112",{"styleChecked":"#CC
CCCC","internalRegionId":"8097072303007107112"});})();
(function(){apex.widget.report.init("R8097072704049107117",{"styleChecked":"#CC
CCCC","internalRegionId":"8097072704049107117"});})();
(function(){com_oracle_apex_simple_checkbox("P23_NONE_CORRECT",{"unchecked":"",
"checked":"Y"});})();
(function(){apex.da.initDaEventList();})(); (function(){apex.da.init();})();
});

Potrebbero piacerti anche