You are on page 1of 2

use try;

create table branch(


branchNo int not null,
street varchar(25) not null,
city varchar(25) not null,
postcode varchar(25) not null,
primary key (branchNo)
);
insert into branch (branchNo, street, city, postcode) values (1006, '65 StreetMa
ll', 'Malvy', 'B35427');
//
//
//
//
ge
//
//

SELECT col_name, col_name, ... FROM table_name WHERE col_name operator value;
select LastName, FirstName, Salary from persons where salary < 100;
select LastName, FirstName, Salary, age from persons where salary < 100 and a
> 40;
select fName, position from staff where position = 'manager' ;

//insert into staff(staffNo, fName, lName, position, sex, DOB, salary, branchNo)
values ('SG14', 'David', 'Ford', 'Supervisor', 'M', 24-3-1958, 18637, 'B007');
use try;
create table privateOwner(
ownerNo varchar(10),
fName varchar(20),
lName varchar(20),
address varchar(35),
telNo int,
primary key (ownerNo)
);
insert into privateOwner (ownerNo, fName, lName, address, telNo) values ('CO46',
'Joe', 'Keogh', '2 Forgus Dt, Aberden ABX76T', 01928371);
select count(*) from table_name; // the count() function returns the
// number of rows that matches a specified crit
eria
select count(col_name) as other_col_name from
table_name where col_name = val; // between time1 and time2
select sum(col_name) from table name; //sum all the thing
select count(staffNo) as myCount, sum(salary) as mySum from staff where position
= 'Manager'
select max(col_name) from table_name;
select min(col_name) from table_name;
select avg(col_name) from table_name;
select tcol_name, aggregate_funct(col_name) from table_name where col_name opera
tor val group by col_name;
select branchNo count(staffNo) as myCount, sum(salary), mySum, from staff group
by branchNo, order by branchNo; // group by col_name having agregate_funct(col_
name) operator value;

select staffNo, fName, lName, position from staff where branchNo = (select branc
hNo, from branch where street = '163 Main St');

You might also like