## Introduction  
Welcome to Lesson 3.1: Writing Basic SQL Queries. This lesson is part of Module 3: Advanced Application - SQL for Data Management in the Data Analytics and SQL for AEC Professionals course. In this lesson, we'll explore the fundamental components of SQL syntax, the structure of SELECT statements, and provide practical examples relevant to the Architecture, Engineering, and Construction (AEC) industry. By the end of this lesson, you will be able to write simple SQL queries to retrieve data from databases effectively. 

## Main Content  

### Introduction to SQL Syntax  
Structured Query Language, or SQL, is the standard language used for managing and manipulating relational databases. Understanding the basic syntax of SQL is crucial for effectively querying data. SQL commands are generally divided into several categories, including Data Query Language (DQL), Data Definition Language (DDL), and Data Manipulation Language (DML). 

In this lesson, we will focus primarily on DQL, which allows you to retrieve data from a database. The fundamental components of an SQL statement include keywords, clauses, and expressions. Keywords are predefined words like SELECT, FROM, and WHERE, which signal what action you want the database to perform. Clauses are parts of the query that specify conditions or criteria, while expressions allow for calculations and filtering of data. 

### SELECT Statements and Query Structure  
The SELECT statement is the cornerstone of SQL queries. It allows you to specify which columns of data you want to retrieve from a database table. The basic structure of a SELECT statement follows this format:

```sql
SELECT column1, column2, ...
FROM table_name
WHERE condition;
```

- **SELECT**: This keyword indicates which columns to fetch.
- **FROM**: This clause specifies the table from which to retrieve data.
- **WHERE**: This optional clause filters records that meet specified conditions.

For example, if you were working with a database that includes a table called `Projects`, and you wanted to retrieve the `ProjectName` and `Budget`, your SQL query would look like this:

```sql
SELECT ProjectName, Budget
FROM Projects;
```

This query retrieves all project names and their respective budgets from the `Projects` table. If you wanted to filter this data to show only projects with a budget greater than $10,000, you would modify the query as follows:

```sql
SELECT ProjectName, Budget
FROM Projects
WHERE Budget > 10000;
```

### Basic Query Examples Relevant to AEC  
To make the concept of SQL more relatable, let’s explore some practical examples that reflect common scenarios in the Architecture, Engineering, and Construction industry.

**Example 1: Retrieving Employee Data**  
Imagine you have a table called `Employees` that contains information about your team members. If you want to find all employees who are architects, you can execute the following SQL query:

```sql
SELECT EmployeeName, Role
FROM Employees
WHERE Role = 'Architect';
```

This query fetches the names and roles of all employees whose role is 'Architect'.

**Example 2: Project Timeline**  
Assume you have a table named `ProjectTimeline`, which tracks different phases of your projects. To retrieve all projects that are currently in the 'Design' phase, you could write:

```sql
SELECT ProjectID, ProjectName, Phase
FROM ProjectTimeline
WHERE Phase = 'Design';
```

This query will display the project IDs and names of projects currently in the design phase, helping you keep track of project progress.

**Example 3: Cost Analysis**  
You might want to analyze the costs associated with various projects to ensure they remain within budget. If you have a `Costs` table, you could query for projects exceeding their budget like this:

```sql
SELECT ProjectName, ActualCost, Budget
FROM Costs
WHERE ActualCost > Budget;
```

This query lists projects where the actual cost has surpassed the allocated budget, allowing for timely financial assessments.

## Conclusion  
In this lesson, we discussed the essential components of SQL syntax, focusing on SELECT statements and their structure. We also provided relevant examples from the AEC industry to illustrate how you can apply these concepts in real-world scenarios. By mastering basic SQL queries, you will enhance your ability to retrieve and analyze data effectively, empowering you to make data-driven decisions in your projects.

## Reflection Questions  
1. How would you modify a SELECT statement to include multiple conditions using the WHERE clause?  
2. Can you think of a scenario in your current job where retrieving specific project data could improve your workflow?  
3. What steps would you take to ensure that your SQL queries return accurate and relevant data?

*Total word count: 1,028 words*