You are on page 1of 1

create table Qa_emp

(
ID int,
Name varchar(20),
Sal int
)
insert into TableA values
(1 ,'A' ,1000),
(2 ,'B' ,2000),
(3, 'C' ,3000),
(4 ,'A ',1000),
(5 ,'D' ,3000),
(6 ,'B', 4000)
create table Qa_dept
(
ID int,
Dept_ID int
)
insert into TableB values
( 1 ,1),
(2 ,2),
(NULL ,NULL),
(4 ,3),
(5 ,3)

select * from Qa_emp


select * from Qa_dept

Select count(*) from TableB


Select count(ID) from TableB
Select A.ID,B.ID
from TableA A,TableB B
where A.id=B.id
select %%physloc%% from TableA
------------------------------------
select name
from TableA
where %%physloc%% = (select Min(%%physloc%% ) from TableA)
union all
select lower(name )
from TableA
where %%physloc%% > (select MIN(%%physloc%% ) from TableA)
---------------------------------------
select top 1 Name
from TableA
union all
select lower(name)
from TableA
where Name not in (select top 1 Name
from TableA)

You might also like