Fetch Transactions for July 2015 in SQL Server

Welcome to Excel Jet Consult blog post. In this SQL Server video tutorial, we are going to learn how to write the SQL query to fetch all the transactions for July 2015 for specific columns. Let’s get started.

Dataset

In the screenshot below, we used a simple select all statement to return all the records in the sale table. The dataset contains 2,080 records

Fetch Transactions for July 2015 in SQL Server

To return all the transactions that occurred on July 2015 in SQL Server, we are going to execute this query:

—Transactions for the month of July of 2015
SELECT [Order Date], [Customer Address], [Account Manager], [Order Quantity] FROM sales
WHERE YEAR([ORDER DATE])=2015 AND MONTH([ORDER DATE])=7;

Select the query and Execute

Query Explanation

The SELECT [Order Date], [Customer Address], [Account Manager], [Order Quantity]  is used to specify the columns we want to retrieve from the sales table. The WHERE YEAR([ORDER DATE])=2015 AND MONTH([ORDER DATE])=7 restricts the results to only include transactions that meet specific criteria the following criteria: YEAR([ORDER DATE])=2015 and MONTH([ORDER DATE])=7:

From the screenshot above, we have been able to retrieve all the 64 transactions that occurred in July 2015.

See you in the next tutorial.

 

 

Posted in Blog.

Leave a Reply

Your email address will not be published. Required fields are marked *