O'Reilly logo

Mastering SQL Queries for SAP Business One by Gordon Du

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with a subquery

A subquery is a very useful tool to solve certain special problems. It can return values to form a condition or to add a column. There are mainly three different usages:

  • Subquery under a Where clause
  • Subquery as a standalone column
  • Subquery within a subquery

    Tip

    Although you can add a subquery within a subquery and the level for subquery can be more than two, it is not recommended. The more sublevels that exist in your query, the more trouble you may end up with. It is not worth the effort to create such a monster-like query unless you do not have any other choice.

The following query example cases belong to the first two categories. No subquery within a subquery is shown here due to the obvious reason just mentioned.

Case 9-S1—Item ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required