You are on page 1of 4

UN (United Nation)

standbyroster@gmail.com
standbyroster.org
Technical Questions for Database Developer
Time to
complete:
Returns before 201!12!0" 12:00(#$T)
estimated completion time: 60 minutes
Test %b&ective: This test is designed to assess your knowledge of SQL and
your understanding of data structures especially your ability
to e!tract useful information from SQL Ser"er databases. #ote
that while the $ob function itself in"ol"es a higher application
of your technical skills this test assesses rudimentary
technical knowledge. %urther technical and functional
competencies will be assessed at the time of ad"anced test
and inter"iews if you are short&listed following this test.
'. (i"en the table structure and sample data gi"en below write a SQL
statement to output: )egion*+ Sales ,ro-t ,ro-t .. /0 points1
Table 'Re(ional$ales):
*olumn
Name
Data
T+pe
,ttribute
s
)egion*+ *#T ,2
Sales *#T #3T #4LL
,ro-t *#T #3T #4LL
$ample Data:
Re(ion-
D
$ales #ro.t
' '000000 '0056
6 6000000 '7809
8 8000000 80'60
5 5000000 9'860
0 0000000 '8090
Select )egion*+ Sales ,ro-t/pro-t:sales1;'00 as <,ro-t .= from
)egionalSales>
6. (i"en the table structures below write SQL statements as described
below. /'0 points1
Table ',dmin/0penditure):
*olumn
Name
Data T+pe ,ttributes
*+ *#T ,2
)egion*+ *#T #3T #4LL
%2
?!penditur
e
#4@?)*A/89
61
#3T #4LL
Table '-mplementationRevenue):
*olumn
Name
Data T+pe ,ttributes
*+ *#T ,2
)egion*+ *#T #3T #4LL
%2
)e"enue #4@?)*A/89
61
#3T #4LL
3utput columns of all SQL statements should be: )egion*+ ?!penditure
)e"enue
/a1 Brite SQL to list all regions with Cdministrati"e ?!penditure and
*mplementation )e"enue.
select a.)egion*+ a.?!penditure i.)e"enue
from
Cdmin?!penditure a
$oin *mplementation)e"enue i on i.regionDidEa.regionDid
/b1 Brite SQL to list all regions with Cdministrati"e ?!penditure but no
*mplementation )e"enue.
select a.)egion*+ a.?!penditure i.)e"enue
from
Cdmin?!penditure a
$oin *mplementation)e"enue i on i.regionDidEa.regionDid
where isnull/i.re"enue01F0
/c1 Brite SQL to list all regions with *mplementation )e"enue but no
Cdministrati"e ?!penditure.
select a.)egion*+ a.?!penditure i.)e"enue
from
Cdmin?!penditure a
$oin *mplementation)e"enue i on i.regionDidEa.regionDid
where isnull/a. ?!penditure01F0
/d1 Brite SQL to list all regions that ha"e either Cdministrati"e ?!penditure
or *mplementation )e"enue.
select a.)egion*+ a.?!penditure i.)e"enue
from
Cdmin?!penditure a
$oin *mplementation)e"enue i on i.regionDidEa.regionDid
where/ isnull/a. ?!penditure01F0 or isnull/i.re"enue01F01
8. (i"en the table structure below write a SQL statement to output ,ro$ect*+
Ccti"ity*+ %ee,ct with the latest e1ective date less than or eGual to the
current date /the output should contain a single row for each ,ro$ect*+ and
Ccti"ity*+ combination1 . /'0 points1
Table '2eeRates):
*olumn
Name
Data T+pe ,ttributes
*+ *#T ,2
?Hecti"e+a
te
+ateTime #ot #4LL
,ro$ect*+ IC)AJC)/91 #3T #4LL
%2
Ccti"ity*+ Iarchar/601 #3T #4LL
%2
%ee,ct #umeric/661 #3T #4LL
select ,ro$ect*+KL LKCcti"ity*+ %ee,ct
from %ee)ates
where ma!/?Hecti"e+ate1MEgetdate/1
5. Brite SQL statements that: /a1 *nsert records into the Austomer3rderTotals
table with rows for each customer that placed orders if the rows donLt
already e!ist> /b1 4pdate the 3rderCmount column of the
Austomer3rderTotals to eGual the total amount of orders placed by each
customer in the speci-c period and -scal year. /60 points1
Table '*ustomer%rderTotals):
*olumn
Name
Data T+pe ,ttributes
Austomer3rd
er*+
*#T ,2
Austomer*+ *#T #3T #4LL
%2
%iscalNear *#T #3T #4LL
,eriod *#T #ot #4LL
3rderCmount #4@?)*A/89
61
#3T #4LL
Table '%rders):
*olumn
Name
Data T+pe ,ttributes
3rder*+ *#T ,2
Austomer*+ *#T #3T #4LL
%2
%iscalNear *#T #3T #4LL
,eriod *#T #ot #4LL
Table '%rder-tems):
*olumn
Name
Data T+pe ,ttributes
3rder*tem*+ *#T ,2
3rder*+ *#T #3T #4LL
%2
,roduct*+ *#T #ot #4LL %2
LineCmount #4@?)*A/89
61
#3T #4LL
/a1.
@erge Austomer3rderTotals as A
4sing /selec 3rder*+Austomer*+%iscalNear,eriod1 from 3rders 3
on A.Austomer*+E3.Austomer*+
when not matched then
insert/A.Austomer3rder*+A.Austomer*+A.%iscalNearA.,eriodA.3rderCmo
unt1
ICL4?S/3.3rder*+3.Austomerid3.%iscalNear3.,eriod1
/b1.
update Austomer3rderTotals A
set c.3rderCmount E 3*.LineCmount
$oin 3rder 3 on 3.Austomer*+Ec.Austomer*+ and 3.%iscalNearEA.%iscalNear
and 3.,eriodEA.,eriod
$oin 3rder*tems 3* on 3*.3rder*+E3.3rder*+
0. (i"en the below table write a SQL Guery that would return the list of
students that are enrolled in all 8 courses CO and A. /'0 points1
Table ($ample Data): /nrolment
$tudent-D *ourse-D
Pohn C
Pohn O
Pohn A
@ary C
@ary C
@ary (
@ary J
Pane C
Pane O
Pane A
Select distinct student*+ from
?nrolment where Aourse*+ in /QCLLOLLAL1

You might also like