IT Project thors
IT Project thors
Query:
sql
Explanation: This query retrieves all columns and records from the employees
table.
Output:
2. Instruction: Select only the name and age columns from the employees
table.
Query:
sql
Explanation: This query retrieves only the name and age columns of all
employees.
Output:
| name | age |
|-------------|-----|
| John Smith | 30 |
| Jane Doe | 25 |
| Robert Lee | 40 |
| Emily Davis | 28 |
| Michael Roy | 35 |
Query:
sql
Explanation: This query counts the total number of rows in the employees
table.
Output:
| COUNT(*) |
|----------|
| 5 |
Query:
sql
Explanation: This query calculates the average salary of all employees in the
table.
Output:
| AVG(salary) |
|-------------|
| 61400 |
Query:
sql
Explanation: This query returns the highest salary in the employees table.
Output:
| MAX(salary) |
|-------------|
| 75000 |
Query:
sql
Explanation: This query returns the lowest salary in the employees table.
Output:
| MIN(salary) |
|-------------|
| 50000 |
Query:
sql
Explanation: This query retrieves all employees who work in the IT department.
Output:
Query:
sql
Explanation: This query returns a list of unique department names from the
employees table.
Output:
| department |
|------------|
| HR |
| IT |
| Finance |
Query:
sql
Explanation: This query retrieves the name of employees who are older than 30
years.
Output:
| name |
|-------------|
| Robert Lee |
| Michael Roy |
Query:
sql
SELECT name, salary FROM employees ORDER BY salary
DESC;
Explanation: This query retrieves the name and salary columns of all
employees, sorted in descending order of salary.
Output:
| name | salary |
|-------------|--------|
| Robert Lee | 75000 |
| Emily Davis | 65000 |
| Jane Doe | 60000 |
| Michael Roy | 52000 |
| John Smith | 50000 |
11. Instruction: Retrieve the first 3 records from the employees table.
Query:
sql
Explanation: This query retrieves the first 3 records from the employees table.
Output:
Query:
sql
Query:
sql
UPDATE employees
SET salary = 70000
WHERE id = 2;
Query:
sql
15. Instruction: Retrieve the names and ages of employees whose age is
between 25 and 35.
Query:
sql
Explanation: This query retrieves employees whose age is between 25 and 35,
inclusive.
Output:
| name | age |
|-------------|-----|
| Jane Doe | 25 |
| Emily Davis | 28 |
| Michael Roy | 35 |
Program:
java
Output:
Hello World
Program:
java
Explanation: This program adds two numbers, a and b, and prints the sum.
Output:
Sum: 15
Program:
java
Explanation: This program compares two numbers and prints the larger one.
Output:
20 is the largest
Program:
java
Output:
1
2
3
4
5
6
7
8
9
10
Program:
java
public class Sum {
public static void main(String[] args) {
int a = 7, b = 8;
int sum = a + b;
System.out.println("Sum: " + sum);
}
}
Explanation: This program calculates and prints the sum of two numbers.
Output:
Sum: 15
Program:
java
public class ReverseString {
public static void main(String[] args) {
String str = "Hello";
String reversed = new
StringBuilder(str).reverse().toString();
System.out.println("Reversed: " + reversed);
}
}
Explanation: This program reverses the string "Hello" and prints it.
Output:
Reversed: olleH
Program:
java
Explanation: This program checks if a number is even or odd and prints the result.
Output:
10 is even
Program:
java
Explanation: This program calculates the factorial of a number and prints it.
Output:
Factorial: 120
Program:
java
Output:
Sum of elements: 15
Program:
java
Output:
Program:
java
public class NumberSign {
public static void main(String[] args) {
int number = -5;
if (number > 0) {
System.out.println(number + " is
positive");
} else if (number < 0) {
System.out.println(number + " is
negative");
} else {
System.out.println("The number is zero");
}
}
}
Output:
-5 is negative
Program:
java
Output:
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
...
7 * 10 = 70
Program:
Java
Output:
Largest number: 7
Program:
java
Output:
7 is prime
Program:
java
Explanation: This program calculates the area of a circle using the formula: π *
r².
Output:
1. W3Schools
W3Schools was used as a reference for learning and understanding
the basics of MySQL and Java.
o MySQL Tutorial: https://www.w3schools.com/sql/
o Java Tutorial: https://www.w3schools.com/java/
2. GeeksforGeeks
GeeksforGeeks provided additional examples and explanations for
both MySQL queries and Java programs.
o MySQL: https://www.geeksforgeeks.org/mysql-tutorial/
o Java: https://www.geeksforgeeks.org/java/