Return a 'scalar' representation of this selectable, which can be used as a column expression. The returned object is an instance of :class:`_sql.ScalarSelect`. Typically, a select statement which has only one column in its columns clause is eligible to be used as a
(self)
| 3767 | return Exists(self) |
| 3768 | |
| 3769 | def scalar_subquery(self) -> ScalarSelect[Any]: |
| 3770 | """Return a 'scalar' representation of this selectable, which can be |
| 3771 | used as a column expression. |
| 3772 | |
| 3773 | The returned object is an instance of :class:`_sql.ScalarSelect`. |
| 3774 | |
| 3775 | Typically, a select statement which has only one column in its columns |
| 3776 | clause is eligible to be used as a scalar expression. The scalar |
| 3777 | subquery can then be used in the WHERE clause or columns clause of |
| 3778 | an enclosing SELECT. |
| 3779 | |
| 3780 | Note that the scalar subquery differentiates from the FROM-level |
| 3781 | subquery that can be produced using the |
| 3782 | :meth:`_expression.SelectBase.subquery` |
| 3783 | method. |
| 3784 | |
| 3785 | .. versionchanged:: 1.4 - the ``.as_scalar()`` method was renamed to |
| 3786 | :meth:`_expression.SelectBase.scalar_subquery`. |
| 3787 | |
| 3788 | .. seealso:: |
| 3789 | |
| 3790 | :ref:`tutorial_scalar_subquery` - in the 2.0 tutorial |
| 3791 | |
| 3792 | """ |
| 3793 | if self._label_style is not LABEL_STYLE_NONE: |
| 3794 | self = self.set_label_style(LABEL_STYLE_NONE) |
| 3795 | |
| 3796 | return ScalarSelect(self) |
| 3797 | |
| 3798 | def label(self, name: Optional[str]) -> Label[Any]: |
| 3799 | """Return a 'scalar' representation of this selectable, embedded as a |
no test coverage detected