FinTech Dev - Assessment Test
Version 2.1
Duration: 60 minutes
Instructions:
i) This is open book test.
ii) There are three mandatory sections in the test:
Section 1: T-SQL
Section 2: C#/.NET/Algorithm
Section 3: JavaScript
Each section has one question.
iii) There is a bonus Section 4 with a supplementary T-SQL question.
Please attempt the bonus question only if you are done with the mandatory sec
iv) You may want to take help of fiddles to test run your code.
Fiddles for C#, JavaScript and T-SQL can be found at link1, link2 and link3 respectively.
[To be able to see output from console.log() in JSFiddle, you may consider using the solution mentioned here]
Section 1: T-SQL
Consider a database that contains following tables.
Write a T-SQL query for a report. The query must meet the following requirements:
Use the first initial of the table as an alias.
Return the most recent order date for each customer.
Retrieve FirstName of the person (who placed the order) as CustomerName.
Return the Order date in a column named MostRecentOrderDate that appears as the last
column in the report.
Return the most recent orders first.
Your answer here:
Select C.FirstName as CustomerName, O.OrderId,O.CustomerID ,O.OrderDate as MostRecentOrderDate
from dbo.orders as O INNER JOIN dbo.Customers as C on (C.CustomerID=O.CustomerID)
Where O.OrderDate = Max(O.OrderDate)
GroupBy C.CustomerName, O.orderID, O.customerID,o.orderDate
Order by O.OrderDate ASC
Section 2: C#/.NET/Algorithm
Write a function that, when passed a list and a target sum, prints combinations of all numbers, whose
sum is equal to the target sum. If there are no two numbers, the function should print “no pair found”.
For example,
FindTwoSum(new List<int>() { 3, 1, 5, 7, 5, 9 }, 10)
Should print in the console
{3, 7}
{1, 9}
{5, 5}
Your answer here:
using System;
using System.Collections.Generic;
Class Mine
Static bool FindTwoSum(List<Int> numbers, int Sum)
Int size = numbers.count;
sort(numbers, 0, size - 1);
Int l,r
while (l < r) {
if (numbers[l] + numbers[r] == sum)
Console.Writeline(numbers[l], numbers[r]);
return true;
else if (numbers [l] + numbers[r] < sum)
l++;
else // numbers[i] + numbers[j] > sum
r--;
}
return false;
console.writeline(“no pair fpund”)
static int partition(List<Int> numbers, int low, int high)
{
int pivot = numbers[high];
// index of smaller element
int i = (low - 1);
for (int j = low; j <= high - 1; j++) {
// If current element is smaller
// than or equal to pivot
if (numbers[j] <= pivot) {
i++;
int temp = numbers [i];
numbers [i] = numbers [j];
numbers [j] = temp;
}
}
int temp1 = numbers [i + 1];
numbers [i + 1] = numbers [high];
numbers [high] = temp1;
return i + 1;
}
static void sort(List<Int> numbers, int low, int high)
{
if (low < high) {
int pi = partition(numbers, low, high);
sort(numbers, low, pi - 1);
sort(numbers, pi + 1, high);
}
}
public static void Main ()
{
List<int> numbers = new List<int>() {3,1,5,7,5,9};
int Sum = 10;
FindTwoSum (numbers, sum)
}
}
Section 3: JavaScript
Write a function called getClone that takes an object and creates an object copy of it but does not copy
deep property of the input object.
Example:
var obj = {foo : 'Bar'};
var cloneObj = getClone(obj); // getClone is the function which you have to write
console.log(cloneObj === getClone(obj)); // this should return false
console.log(cloneObj == getClone(obj)); // this should return true
Your answer here:
Var obj = {foo : ‘Bar’};
Var CloneObj = getClone(obj);
Console.log(CloneObj === GetClone(obj))
Console.log(CloneObj == GetClone(obj))
GetClone(Obj)
Let copy = obj;
Obj.foo=’Bar’;
Section 4: Bonus T-SQL
Consider the same two tables from previous T-SQL question.
Write a T-SQL query for a report. The query must meet the following requirements:
Use the first initial of the table as an alias.
Return year and month wise total sales count.
First column should be years in ascending order. The remaining columns should be twelve
months.
An example query output:
Your answer here:
Select Year(o.orderdate) as SalesYear,
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 1) as ‘Jan’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 2) as ‘Feb’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 3) as ‘Mar’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 4) as ‘Apr’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 5) as ‘May’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 6) as ‘Jun’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 7) as ‘Jul’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 8) as ‘Aug’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 9) as ‘Sep’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 10) as ‘Oct’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 11) as ‘Nov’
Count(DatePart(month, O.orderdate) from o where DatePart(month, O.orderdate) = 12) as ‘Dec’
From dbo.orders as o
Order by Year(O.orderdate), month(o.orderdate)
Group by Year(O.orderdate), month(o.orderdate)