SQL Server hangs querying 2 independent tables

Tri*_*ung 2 sql sql-server

I am querying 2 independent tables but related data.

The query is as follows:

select 
    STDEV(M1.[Close]) as M1, STDEV(M2.[Close]) as M2 
from 
    M1, M2;
Run Code Online (Sandbox Code Playgroud)

I want to show 2 standard deviation data on separate columns.

But SQL Server hangs there and stops moving. Why is that? It is a very simple query.

How can I do so without crossing 2 tables? The tables are huge.

Ser*_*lan 5

you can use this.

 SELECT 
   (SELECT STDEV(M1.[Close]) from M1) as M1 , 
   (SELECT STDEV(M2.[Close]) from M2) as M2;
Run Code Online (Sandbox Code Playgroud)