CHAR(n) - all characters should be n size. VARCHAR(n) - all characters can less than n size. TEXT - unlimited size. INT - integer. BIGINT - big integer. FLOAT - float. DOUBLE - double.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE C4042; | |
CREATE TABLE Employee( | |
Empno INT, | |
FirstName VARCHAR(20), | |
LastName VARCHAR(20), | |
Address VARCHAR(100), | |
City VARCHAR(25), | |
Desgn VARCHAR(25), | |
DeptId INT, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT Empno,FirstName,LastName, DeptId FROM Employee ORDER BY FirstName; | |
SELECT Empno,FirstName,LastName, DeptId FROM Employee ORDER BY LastName, FirstName; | |
SELECT Empno,FirstName,LastName, DeptId FROM Employee WHERE LastName LIKE '%H%'; | |
SELECT Empno,FirstName,LastName, DeptId FROM Employee WHERE SUBSTR(LastName,3,1) = 'H'; | |
SELECT DISTINCT City FROM Employee; | |
SELECT Empno,FirstName,LastName, DeptId FROM Employee WHERE Salary BETWEEN 30000 AND 45000; | |
SELECT Empno,FirstName,LastName, City FROM Employee WHERE City NOT IN ('Mumbai','Pune'); | |
SELECT DeptId, SUM(Salary), AVG(Salary), MAX(Salary), MIN(Salary) FROM Employee GROUP BY DeptId; | |
SELECT Empno, LOWER(FirstName), UPPER(LastName), SUBSTR(LastName,3,4) FROM Employee; | |
SELECT Empno, CONCAT(FirstName, ' ', LastName) AS Name FROM Employee; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT e.Empno, e.LastName, d.DeptName from Employee e, Department d WHERE e.DeptID = d.DeptId ORDER BY d.DeptName,e.LastName DESC; | |
SELECT e.lastName, d.DeptID, d.DeptName from Employee e, Department d WHERE e.DeptID = d.DeptId; | |
SELECT DISTINCT desgn from Employee where DeptId = 1; | |
SELECT e.LastName, d.DeptName from Employee e, Department d WHERE e.LastName LIKE '%a%' AND e.DeptId = d.DeptID; | |
SELECT e.LastName, d.DeptName, d.City from Employee e, Department d WHERE e.DeptId = d.DeptId AND e.desgn = 'Manager' ORDER BY e.Empno; | |
SELECT CONCAT(e.FirstName, " ", e.LastName) "Employee", CONCAT(m.LastName, " ", m.FirstName) FROM Employee m INNER JOIN Employee e ON m.Desgn="Manager" AND e.DeptID = m.DeptId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select d.DeptName, Min(salary) "Minimum Salary", Max(Salary) "Maximum Salary" from employee e, department d where e.DeptId=d.DeptId group by e.deptId; | |
SELECT Desgn, COUNT(Desgn) FROM Employee GROUP BY Desgn; | |
SELECT Desgn, MIN(Salary), MAX(Salary), SUM(Salary), AVG(Salary) FROM Employee GROUP BY Desgn; | |
SELECT MAX(Salary) - MIN(Salary) AS 'Range of Salary' FROM Employee; | |
select m.Empno "Manager ID", e.Salary "Minimum Salary" from Employee m, Employee e where e.DeptId=m.DeptId AND m.Desgn ="Manager" AND e.Salary = (select MIN(Salary) from Employee where DeptID=m.DeptId) ORDER BY e.FirstName DESC; | |
select d.deptId, empno, concat(FirstName, " ", LastName) "Employee Name", Salary from Employee d INNER JOIN Department e on d.deptId =e.deptId WHERE salary>(select AVG(salary) from Employee); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package DataStructures; | |
public class CaesarCipher { | |
static String encrypt(String msg, int key){ | |
StringBuilder encrypted = new StringBuilder(msg); | |
String alphabets = "ABCDEFGHIJKLMNOPQRSTVUWXYZ"; | |
String smallalphabets = alphabets.toLowerCase(); | |
String shiftedAplhabets = alphabets.substring(key) + alphabets.substring(0, key); | |
for( int i =0; i< encrypted.length(); i++){ | |
char curChar = encrypted.charAt(i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" prove by mathematical induction n(n+1)(n+2) is divisible by 24 """ | |
def main(n): | |
""" main function """ | |
if n * (n + 1) * (n + 2) % 6 == 0: | |
print(n, "is divisible by 6") | |
return main(n + 1) | |
else: | |
print(n, "is not divisible by 6") | |
n += 1 | |
return main(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
public class Main { | |
public static void main(String[] args) { | |
/*read lines from fle adn conver in tor array*/ | |
String[] lines = new String[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table student(rno int(5) primary key, name varchar(10) not null, address varchar(30), phone varchar(10)); | |
create table marks(rno int(5), maths int(3), cs int(3), phy int(3), bio int(5), chem int(5)); | |
insert into student values (1, "Abhay", "Bengaluru", "1000000000"), (2,"Arin","Hyderabad", "2000000000"), (3,"Om", "Pune", "3000000000"),(4, "Asha", "Mumbai", "5000000000"), (5, "Kapil", "Delhi", "5000000000"); | |
insert into marks values (1, 234, 432,354, 456, 343), (2,453,655,654,765,134), (3, 382,891,329,839,177),(4,928,314,533,242,659),(5,392,432,565,732,676); | |
select s.rno "Roll Number", name "Name", SUM(maths+cs+phy+bio+chem) "Total Marks" from student s inner join marks m on s.rno=m.rno group by s.rno; |
OlderNewer