You can use an expression in many places in an SQL statement, as the following examples show. Expressions are shown in bold text.
Expression | Result |
---|---|
SELECT [FirstName], [LastName] FROM [Employees] WHERE [LastName] = "Davolio"; | Displays the values in the FirstName and LastName fields for employees whose last name is Davolio. |
SELECT [ProductID], [ProductName] FROM [Products] WHERE [CategoryID] = Forms![New Products]![CategoryID]; | Displays the values in the ProductID and ProductName fields in the Products table for records in which the CategoryID value matches the CategoryID value specified in an open New Products form. |
SELECT Avg([ExtendedPrice]) AS [Average Extended Price] FROM [Order Details Extended] WHERE [ExtendedPrice] > 1000; | Displays in a field named Average Extended Price the average extended price of orders for which the value in the ExtendedPrice field is more than 1,000. |
SELECT [CategoryID],Count([ProductID]) AS [CountOfProductID] FROM [Products] GROUP BY [CategoryID] HAVING Count([ProductID]) > 10; |
Displays in a field named CountOfProductID the total number of products for categories with more than 10 products. |