SQL for Data Analysis
- 35Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- āPrevious card
- āNext card
What does SQL stand for and what is it used for?
Structured Query Language; a language for interacting with databases to retrieve, filter, sort, add, update, and remove data.
Or swipe the card
35 cards
What does SQL stand for and what is it used for?
Structured Query Language; a language for interacting with databases to retrieve, filter, sort, add, update, and remove data.
What is a database?
A collection of related tables that store data, often with relationships between them.
What does RDBMS stand for?
Relational Database Management System.
What is the difference between the SQL Server Express and Developer editions?
Express: free for business use, limited to 10 GB database size and 4 cores. Developer: full functionality but for development/testing only, not for production use.
How do you verify that SQL Server is running after installation?
Open SQL Server Configuration Manager (Start > All Apps > Microsoft SQL Server 2019 > Configuration Manager) and check the service status (running, start mode automatic).
What is SQL Server Management Studio (SSMS) and its purpose?
A graphical tool that provides an interface to connect to SQL Server instances and write queries, manage databases, and view results.
How do you connect to a SQL Server instance in SSMS?
In the 'Connect to Server' dialog, provide the server name (your PC name, found via 'Browse for more' > 'Database Engine'), choose Windows Authentication, and click Connect.
How do you restore a database backup in SSMS?
Right-click 'Databases' in Object Explorer > 'Restore Database...' > select 'Device' > browse to the .bak file > OK.
What are tables, fields, and records in a database?
Tables: database objects that store data in rows and columns. Fields: columns representing attributes. Records: rows representing individual entries.
What is a primary key?
The minimum number of columns that uniquely identify a row in a table, often an ID column.
What is normalization in databases?
Designing tables to minimize data repetition by breaking data into separate related tables, reducing redundancy and improving efficiency.
What is a schema in SQL Server?
A container for database objects (like tables) that groups them logically and can be used to manage access permissions.
What is the purpose of the
SELECTstatement?To retrieve data from one or more tables in a database.
How do you specify which database to query?
Use a three-part naming convention:
DatabaseName.SchemaName.TableName(e.g.,KCC.dbo.customers). Alternatively, select the database from the dropdown in SSMS.What does the
DISTINCTkeyword do?Removes duplicate rows from the result set, returning only unique values for the selected columns.
How do you rename a column in the result set using an alias?
Use the
ASkeyword followed by the desired name, e.g.,SELECT customer_name AS [Customer Name] FROM customers;What does the
TOPclause do in SQL?Limits the number of rows returned in the result set to a specified count (e.g.,
SELECT TOP 3 * FROM customers;returns the first 3 rows).How do you filter rows using the
WHEREclause?Specify conditions after
WHERE, e.g.,SELECT * FROM customers WHERE state = 'Washington';What operators can be used with
WHEREto combine conditions?AND(both conditions true),OR(at least one true), parentheses for grouping logic.How does the
LIKEoperator work with the%wildcard?LIKEmatches patterns.%represents any sequence of characters.'A%'matches strings starting with 'A','%A%'matches any string containing 'A'.How do you sort query results?
Use
ORDER BY column_name ASC(ascending, default) orDESC(descending).What is the purpose of comments in SQL?
To explain code or temporarily disable parts. Two dashes (
--) for single-line comments;/* ... */for multi-line comments.What is a JOIN and why is it used?
A JOIN combines rows from two or more tables based on a related column (e.g., primary key/foreign key relationship).
What is an INNER JOIN?
Returns only rows where there is a match in both tables; no NULLs for unmatched rows.
What is a LEFT OUTER JOIN?
Returns all rows from the left table, and matching rows from the right table; if no match, right table columns are NULL.
What is a RIGHT OUTER JOIN?
Returns all rows from the right table, and matching rows from the left table; if no match, left table columns are NULL.
How do you handle ambiguous column names in a JOIN?
Prefix the column with the table name or alias (e.g.,
customers.CustomerIDorc.CustomerID).What is the purpose of table aliases?
Shorthand names for tables, making queries shorter and easier to read (e.g.,
FROM orders AS o JOIN customers AS c ON o.CustomerID = c.CustomerID).How do you use the
GETDATE()function?Returns the current system date and time. Often used in comparisons, e.g.,
WHERE order_date >= DATEADD(month, -1, GETDATE()).What does
DATEADD(interval, number, date)do?Adds a specified number of intervals (e.g., months, days) to a date and returns the new date.
How do you count rows in a result set?
Use
COUNT(*)orCOUNT(column)to return the number of rows.COUNT(*)counts all rows including NULLs;COUNT(column)counts non-NULL values.How do you sum numeric column values?
Use
SUM(column_name)to get the total of all values in that column.What does
GROUP BYdo?Groups rows that have the same values in specified columns into summary rows, often used with aggregate functions (COUNT, SUM, AVG, etc.).
What is the Query Designer in SSMS?
A visual tool that automatically generates SQL queries by allowing you to select tables, columns, filters, sorts, and groups via a drag-and-drop interface.
How do you add a filter condition in the Query Designer?
In the grid, under the 'Filter' column for the desired field, type the condition (e.g.,
>= '2/18/2022'). The tool adds aWHEREclause automatically.

Ask anything
We've read this whole study set, so questions about it get the best answers.