0% found this document useful (0 votes)
62 views8 pages

PT. IFS Solusi Integrasi PT Haluan Rekadaya Konsultindo: Sales - Id Sales - Name Join - Date (MM-DD-YYYY) Manager

Here are the functions to solve the programming problems: 1. This function displays a triangle pattern of asterisks: ``` 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; } } ``` 2. This function checks if a number is prime: ``` bool isPrime(int n){ for(int i=2; i<n; i++){ if(n

Uploaded by

Fauzi Z
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views8 pages

PT. IFS Solusi Integrasi PT Haluan Rekadaya Konsultindo: Sales - Id Sales - Name Join - Date (MM-DD-YYYY) Manager

Here are the functions to solve the programming problems: 1. This function displays a triangle pattern of asterisks: ``` 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; } } ``` 2. This function checks if a number is prime: ``` bool isPrime(int n){ for(int i=2; i<n; i++){ if(n

Uploaded by

Fauzi Z
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

PT.

IFS Solusi Integrasi

PT Haluan Rekadaya Konsultindo


Applicant Name: Muhammad Fauzi
Evaluation Date: 23 Juni 2022
Contact Number: 085278321965

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

E0001 Ganesha 02/18/2000 *

E0002 Felicia 08/01/2002 E0001

E0003 Calista 05/10/2003 E0001

E0004 Wiwid 04/06/2006 E0002

Table: branch Table: branch_category


Branch_id Branch_name Branch_Categor Category_Id Name
y

P0001 Jakarta 1 1 Primary

P0002 Medan 2 Secondary

P0003 Makasar 2

Table: branch_assignment
Sales_Id Branch_id valid_from(MM/DD/YYYY) valid_to(MM/DD/YYYY)

E0001 P0001 02/18/2000 01/01/2999

E0002 P0002 08/01/2002 01/01/2999

E0003 P0003 05/10/2003 01/01/2999

E0004 P0001 04/06/2006 01/01/2010


Note : Year 2999, states that the employees are still working in the company, and year 2010 states that
employee has been resigned.

1. Create statement to add the following sales,


Sales Id: E0005, Sales Name: Darryl, Join Date: current date, Manager: E0002
answer: insert into sales (Sales_Id, Sales_Name, join_date, Manager) values (“E0005”,
“Darryl”, “06/23/2022”, “E0002”);
2. Create SELECT statement to get list of all sales with their current branch.
Expected Result:

Sales Id Sales Name Branch Id Branch Name Category


Name

E0001 Ganesha P0001 Jakarta Primary

E0002 Felicia P0002 Medan -

E0003 Calista P0003 Makasar Secondary

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 *

E0002 Felicia E0001 Ganesha

E0003 Calista E0001 Ganesha

E0004 Wiwid E0002 Felicia

E0005 Darryl E0002 Felicia


answer: select s.Sales_Id as “Sales Id”, s.Sales_Name as “Sales Name”, m.Sales_Id as
“Manager Id”, m.Sales_Name as “Manager Name”
from sales s, sales m
where s.Sales_Id <> m.Sales_Id;

4. Select 1 from sales where 1=1 ; will result:

5. Select * from sales where 1=2; will result: empty


6. Select * from branch where branch_id = ‘P00%’; will result: empty
7. Select * from branch where branch_id like ‘P00%’; will result:

Branch_id Branch_name Branch_Category

P0001 Jakarta 1

P0002 Medan

P0003 Makasar 2

8. Define keys for each table above

x sales branch branch_assignm branch_category


ent

primary key Sales_Id Branch_Id Category_Id


foreign keys Manager Branch_Categor Sales_Id,
y Branch_Id

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)

1 E0001 32000 3/1/2010

2 E0002 20000 3/1/2010

3 E0003 40000 3/1/2010

4 E0004 30000 3/1/2010

5 E0001 33000 4/1/2010


6 E0002 21000 4/1/2010

7 E0003 42000 4/1/2010

8 E0004 20000 4/1/2010

9 E0001 34000 5/1/2010

10 E0002 11000 5/1/2010

11 E0003 22000 5/1/2010

12 E0004 55000 5/1/2010

13 E0001 6000 6/1/2010

14 E0002 7000 6/1/2010

15 E0003 8000 6/1/2010

16 E0004 9000 6/1/2010

17 E0001 66000 7/1/2010

18 E0002 11000 7/1/2010

19 E0003 32000 7/1/2010

20 E0004 12000 7/1/2010

21 E0001 34000 8/1/2010

22 E0002 11000 8/1/2010

23 E0003 22000 8/1/2010

24 E0004 55000 8/1/2010

Write SELECT Statement to get the result:

1. Display the sum of sales amount for each sales name


answer:
select s.Sales_name, sum(t.Sales_Amount) as “Total Amount”
from sales s
join sales_transaction t on t.Sales_Id = s.Sales_Id
group by s.Sales_Name;
2. Who has the maximum sales amount, how much and on what date.
select s.Sales_Id, s.Sales_Name, t.Sales_Date, MAX(t.Sales_Amount)
from sales s
join sales_transaction t on t.Sales_Id = s.Sales_Id
group by s.Sales_Id;

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

1. Create function to display the following pattern


*
**
***
****
*****
******
*******
********
*********
**********

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 ;
}

3. You have the following string:


String str = “IFS Solusi Integrasi, PT”; // syntax in java
Use your programming logic to find how many i (or I) in the string.
The Result: 4
String strLower = str.toLowerCase();
int count = 0;
for (int i = 0; i < str.length; i++) {
if (strLower.charAt(i) == “i”) count++;
}

4. You have array of integer


int[] anArray = { 8,20,50,33,89,35,23,90,101,77,23 }; //syntax in java
Use your programming logic to find the greatest integer in that array and display the result
Note: you could use any programming language you’ve known.
The Result: 101

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];

for (int i=2; i <= n; i++) {


f[i] = f[i-1] + f [i-2];
sum += f[i];
}

return sum;
}

You might also like