

Open up the AdventureWorks table and retrieve one month's of data records from the SalesOrderHeader table. a lot of SQL developers write their queries like this. The BETWEEN statement is very helpful! What to see why? You can delete the WHERE clause and run the query again to see why. You can do that by using SSMS's Object explorer to find the database and table then right-clicking the table name and columns to see the column names and their datatypes. You have to know the datatype of the column that you are filtering on first, before you craft your WHERE statement. You should see 174 rows.įor specifying filters in the where clause dates and words have to be in 'single quotes' and numbers do not. You can add many different filters to the WHERE statement, which is pretty important because you rarely want ALL the data rows from a table.

The month of data retrieved is in the WHERE statement. The FROM specifies what table to retrieve the data from. The USE statement tells SSMS what database to operate on. Open up the AdventureWorks database and retrieve either the sales order information for customer #1 (first query) or in the 2nd query one month's of data records from the SalesOrderHeader table. There is a ton of online content that explains what is happening (here’s an example). At this point just play with the queries then slowly create your own.
#ADVENTUREWORKS DATABASE QUERY EXERCISES PASSWORD#
To run these queries, open up SQL Server Management Studio (SSMS) and log into cb-ot-devst12.ad.wsu.edu, userid = mfstudent, password = MIS271.įind the New Query button on the toolbar and one at a time, copy and paste the following T-SQL query syntax, then press the crimson ! to run the query and retrieve data. You can learn a lot about SQL statements quickly just by running them and analyzing the results returned from the database.
