[MS SQL] SELECT

Select all from one table

select * from ForestDistricts

Select columns from table, open more than one select statement

Select Moose, Deer, Boar from LargeWild
select ForestDistrict from ForestDistricts
select * from LargeWild

Select data to copy from one table to another

insert into ForestDistricts 
(ForestID, ForestDistrict, HuntingDistrict)
Select 
ForestID, ForestDistrict, HuntingDistrict from Report$

Select with conditions

Select Deer from LargeWild
where DEER > 2000
Select * from LargeWild
where Deer > 1500 and Moose > 40 
Select ForestDistrict, HuntingDistrict from ForestDistricts
where ForestDistrict like 'A%'
Select ForestDistrict, HuntingDistrict from ForestDistricts
where ForestDistrict like 'E%' or ForestDistrict like 'C%'
Select * from ForestDistricts
where ForestDistrict not like 'DAB%'
Select Distinct ForestDistrict, HuntingDistrict from ForestDistricts
where HuntingDistrict > 31
Select * from ForestDistricts
where HuntingDistrict > 30
order by HuntingDistrict
Select * from ForestDistricts
where HuntingDistrict > 30
group by HuntingDistrict
select  Powiaty, Lisy, Jenoty
from RLO_DROBNA 
order by Lisy asc
select  Powiaty, Lisy, Jenoty
from RLO_DROBNA 
order by Lisy desc

Select IN, BETWEEN

SELECT * FROM SmallWild
WHERE WildRabbits IN (100, 120, 200);
SELECT * FROM SmallWild
WHERE Jackal NOT IN (0, 2, 3, 4, 12);
SELECT * FROM LargeWild
WHERE LW_ID IN (SELECT ForestID FROM ForestDistricts);
SELECT * FROM LargeWild
WHERE LW_ID IN (SELECT SW_ID FROM SmallWild);
SELECT * FROM LargeWild
WHERE Fawn between 1250 and 1300
SELECT * FROM LargeWild
WHERE Mouflon not between 0 and 100

With Aliases and Group by

SELECT HuntingDistrict as H, ForestDistrict as F  
FROM ForestDistricts
WHERE HuntingDistrict between 11 and 15
AND ForestDistrict NOT in ('AUGUSTOW','TULOWICE','WEJHEROWO')
Group by HuntingDistrict,ForestDistrict