Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
my sql2
--Sql Server 2014 Express Edition --Batches are separated by 'go' select @@version as 'sql server version' /* Create a table called NAMES */ CREATE TABLE NAMES(Id int, Name text, salary numeric, mobile numeric, designation text); /* Create few records in this table */ INSERT INTO NAMES VALUES(1,'BHARTI','22700','70114','helpdesk'); INSERT INTO NAMES VALUES(2,'MUKESH','22700','81300','helpdesk'); INSERT INTO NAMES VALUES(3,'NEHA','28600','81307','helpdesk'); INSERT INTO NAMES VALUES(4,'VISHAL','28600','96677','helpdesk'); INSERT INTO NAMES VALUES(5,'SONU','28600','96508','helpdesk'); /* Display all the records from the table */ SELECT * FROM NAMES; SELECT SUM (salary) AS "Total Salary" FROM NAMES; /* Create a table called NIC */ CREATE TABLE NIC(Id int, Name varchar(255), salary varchar(255), mobile varchar(255), designation varchar(255)); /* Create few records in this table */ INSERT INTO NIC VALUES(1,'VIKRANT','40000','12356','TESTER'); INSERT INTO NIC VALUES(2,'KARAN','45000','12353','TESTER'); INSERT INTO NIC VALUES(3,'RAJNISH','45000','12359','TESTER'); INSERT INTO NIC VALUES(4,'GOURAV','42000','12351','TESTER'); INSERT INTO NIC VALUES(5,'JEETESH','43000','12369','TESTER'); /* Display all the records from the table */ SELECT * FROM NIC; ALTER TABLE NIC ADD EMAIL varchar (255); /* Display all the records from the table */ SELECT * FROM NIC; UPDATE NIC SET EMAIL= 'VIKI' WHERE ID ='1' OR ID='3'; /* Display all the records from the table */ SELECT * FROM NIC; SELECT AVG(salary) AS "Total AVARAGE" FROM NAMES; SELECT COUNT(EMAIL) AS "EADD" FROM NIC WHERE EMAIL = 'VIKI'; SELECT TOP 2* FROM NAMES; SELECT MIN(salary) AS LOWESTSALARY FROM NIC; SELECT MAX(salary) AS MAXSALARY FROM NAMES; SELECT NAMES.salary,NIC.designation,NAMES.MOBILE FROM NAMES INNER JOIN NIC ON NAMES.salary=NIC.salary;
run
|
edit
|
history
|
help
0
Libros
Cross and outer apply
db2
practice sql_12AUG
common table expression
bc160402152
Joins outside XML element
tables
Mc170404738
bc160401693