top of page

Query: Pull in Two Columns

 

Select ID, Title

From tbl_Company;

Output:

Query: Pull in Five Columns

 

Select ID, First Name, Last Name, Title, Department

From tbl_Company;

Output:

Query: Find all Districts equal to 5A

 

Select ID, First Name, Last Name, Address, City, State, Zip Code, Company, District, Title, Department

From tbl_Company

Where District = 5a;

Select * From tbl_Amounts

Select  ID, County, Case #, Last Name, First Name, DOB, Amount, Owed, Balance

From tbl_Amounts

Where Owed = 500;

SELECT ID, Sum(Amount) AS SumOfAmount, Sum(Owed) AS SumOfOwed, Sum(Balance) AS SumOfBalance

FROM [tbl_Amounts]

GROUP BY ID;

Here we are going to query for those employees whose first name starts with an 'S' character and works in the Operation department.

Ref: https://o7planning.org/10239/sql-tutorial-for-beginners-with-sql-server#a24074

 

-- Query the employee whose first name starts with S.

Select Emp.Emp_Id

     Emp.First_Name

     Emp.Last_Name

     Emp.Dept_Id

From   Employee Emp

Where  Emp.First_Name Like 'S%';

 

-- Query the employee whose first name starts with S.

-- and work in Operation department.  Dept_Id  = 1.

 

Select Emp.Emp_Id

     Emp.First_Narme

     Emp.Last_Name

     ,mp.Dept_Id

From   Employee Emp

Where  Emp.First_Name Like 'S%'

And    Emp.Dept_Id = 1;

 

This is the result after running the queries:

 

 

 

bottom of page