(,, ,, ) //create Table : 'Xyz' 'Abc' 'Pun'
(,, ,, ) //create Table : 'Xyz' 'Abc' 'Pun'
alter table persons add pcount int identity //add auto increment
field to table here it is pcount
select distinct pid from orders //shows distinct value in column pid
select * from persons where city like 'pun%' //to see data for
specific type (here city starting with pun)
Wildcard Description
select * from persons where pid like '2_' //to see pid with onle
starting 2
select * from persons where pid like '[12]%' //to see pid starting
with 1 0r 2 [] symbolizes it
select * from persons where pid like '[^12]%' //to see pid with
starting not equal to 1 or 2
select top 3 * from persons //to view top 3 roes of persons table(for
top n use n instead of 3)
select top 20 percent * from persons //to view to first top 20%
rows of the total rows in persons table
select * from persons where pid between 2 and 4 //to view data
between range for a particular column
select * from persons where pid not between 2 and 4 //to view data
from given table apart from the mentioned range
SQL JOIN
The JOIN keyword is used in an SQL statement to query data from two or
more tables, based on a relationship between certain columns in these
tables.
create view peor as select pssn,pname from persons inner join orders on
persons.pid=orders.oid //create view using two tables and join query
drop view peor // delete view
select avg(pid)from orders //to get average of a column (Can onle use
it on int type)