You can use an expression in many places in an SQL statement, as the following examples show. Expressions are shown in red.
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; | Calculates the average extended price for orders for which the value in the ExtendedPrice field is more than 1000, and displays it in a field named Average Extended Price. |
SELECT [CategoryID],Count([ProductID]) AS [CountOfProductID] FROM [Products] GROUP BY [CategoryID] HAVING Count([ProductID])>10; |
In a field named CountOfProductID, displays the total number of products for categories with more than 10 products. |