PT. IFS Solusi Integrasi PT Haluan Rekadaya Konsultindo: Sales - Id Sales - Name Join - Date (MM-DD-YYYY) Manager
PT. IFS Solusi Integrasi PT Haluan Rekadaya Konsultindo: Sales - Id Sales - Name Join - Date (MM-DD-YYYY) Manager
SQL
The following question will evaluate your knowledge about SQL Query and Data Manipulation Language
(DML); use any database syntax you’ve known
Table: sales
Sales_Id Sales_Name join_date(MM-DD-YYYY) Manager
P0003 Makasar 2
Table: branch_assignment
Sales_Id Branch_id valid_from(MM/DD/YYYY) valid_to(MM/DD/YYYY)
E0004 Wiwid - - -
(Please notice that for resigned employee E0004, is still displayed but WITHOUT Branch Id, Branch Name
and Category information )
answer: select s.Sales_Id as “Sales Id”, s.Sales_Name as “Sales Name”, b.Branch_Id as “Branch Id”,
b.Branch_Name as “Branch Name”, c.Name as “Category Name ” from sales s
left join branch_assignment ba on s.Sales_id = ba.Sales_Id
left join branch b on b.Branch_id = ba.Branch_Id
left join branch_category c on b.Branch_Category = c.Category_id;
3. Create SELECT statement to get the list of all sales and their manager name.
Sales Id Sales Name Manager Id Manager Name
E0001 Ganesha *
P0001 Jakarta 1
P0002 Medan
P0003 Makasar 2
9. Draw ERD diagram for these tables: sales , branch, branch_category, branch_assignment and
sales_transaction
10. Define any validation needed to prevent invalid data is entered to table branch_assignment
answer:
a. Sales_Id must exist in table sales
b. Branch_Id must exist in table branch
c. valid_to date value must be higher than valid_from date value
Table: sales_transaction
id Sales_Id Sales_Amount Sales_Date(MM/DD/YYYY)
3. Who has the maximum sales amount on each month and how much.
select s.Sales_Name, MONTH(Sales_Date) as month, MAX(Sales Amount) as amount
from sales s
join sales_transaction t on t.Sales_Id = s.Sales_Id
group by month;
Programming
The following question will evaluate your logic programming; use any programming language you’ve
known
answer:
void showPattern(int n)
{
for (int i = 1; i <= n; i++) {
for (int k = n - i; k > 0; k--) {
cout << " ";
}
for (int j = 1; j <= i; j++) {
cout << "*";
}
cout << endl;
}
}
showPattern(10);
2. Create function for checking prime number, return true for prime, false for not prime
Note: Prime Number is 2,3,5,7,11,13, etc
Example: isPrime(3) return true; isPrime(4) return false;
isPrime(int n) {
for (i = 1; i <= n; i++) {
if (n % i == 0) {
c++;
}
}
return c == 2 ;
}
int temp;
int result;
for (int i = 0; i < anArray.length; i++) {
for (int j = i +1; j < anArray.lengthl; j++) {
if(anArray[i] > anArray[j]) {
temp = [anArray[i]];
a[i] = a[j];
a[j] = temp;
}
}
}
result = anArray[anArray.length - 1];
5. Create function to calculate sum of Fibonacci Number based on requested sequence length.
Fibonacci Number is a simple series of numbers in which the sequence of numbers is the sum
of two numbers.
Ex: Input=7
Fibonacci Number = 0,1,1,2,3,5,8.
The Result = 20
answer:
int sumF(int n) {
if (n <= 0) return 0;
int f[n+1];
f[0] = 0, f[1] = 1;
int sum = f[0] + f[1];
return sum;
}