Home   Fees/Services   Access Templates   Tutorials   Tutorial Downloads   Articles   Search   Contact  Privacy  Links
SQL Scalar SubQuery Example
Scalar Query with Aggregate Function Queries
Home > Tutorials > Query Tutorials > Access Scalar Query

Query Tutorials Index:
Too Complex Query
Aggregate Query
Not In Operator
Choose Function
Crosstab Query
Date Time Query
SQL Delete Query
External Table Query
Report Filter Query
Group By Query
Having Query Clause
Histogram Query
Access Append Query
Master Detail Update
Order By Query
SQL Parameter Query
Predicate Query
Self Join Query
Scalar SubQuery
Master Detail Query
Select Query
Access SQL Select Top
SQL Union Query
SQL Update Query
Custom Query Function


MultiSelect Parameter Forms Access Tutorial

Scalar Query

Access scalar query allows you to do in one SQL statement what you are used to doing in two or more queries.

You did not know that nearly 100 cable and satellite tv installers use our software to manage their device inventory. They never lose track of an expensive device.

Did you know that most template databases often do not do exactly what you need done? We can create a custom template that fits your needs exactly.

This function allows retrieval of single values from a table, usually aggregate functions, from within the from clause.

Get individual values while at the same time getting max, min, avg, etc values from the same source without having to use the Group By clause... this greatly simplifies query design.  Here's the setup for our Access subquery example:

SQL Scalar SubQuery

Our goal is the retrieve SSN, Pay_Rate, Max Pay_Rate, Min Pay_Rate,  and calculate each employees' percent of maximum pay rate.

See the following SQL subquery statement:

Access scalar subquery Example

Don't bother trying to create this in the  design grid.  You must get into SQL view.  The key point of the scalar query is:

[select max(pay_rate) as Max_R from m_emp_pay]. as Q_Max  

There are two aliases in this scalar subquery - Max_R for the field and Q_Max for the source name.   Not that an Access SQL alias is an typically an abbreviation for the table or calculated field name.  See how the alias is used in the Select clause of the query.  No group by required!!  Therefore you get the individual pay rates for employees while, at the same time, retrieving min, max, and most importantly the percent of max.

See the results of the scalar subquery below:

Access Subquery Example

The main restriction with scalar subquery SQL statement is that the function can only return a single value, although you can have multiple subquery statements in one main query.

A Blue Claw Software Design Template:

Marina Management Reservations Software

A Blue Claw Database Design Article:

Cloud-Based Access Database

Blue Claw Database Design Downloadable Tutorial:
Bar Chart / Bar Graph Download  

Microsoft Office:
MS Access 2000 Through Access 2016 & Office 365

Contact Information
Copyright 2000-2018 Blue Claw Database Design
Development in Microsoft Access, Microsoft SQL/Server and Azure

See our SQL/Server Development and Access Migration Tutorials