Multiply the amount of elements from two different tables

Asked

Viewed 1,286 times

3

I have two tables: pessoas and carros.

I would like to take the number of elements of both tables, and multiply them.

2 answers

3


I think this is what you want:

SELECT a.c * b.d AS produto
FROM (SELECT COUNT(*) AS c FROM pessoas) a,
     (SELECT COUNT(*) AS d FROM carros) b

2

select 
    (select count(*) from pessoas) *
    (select count(*) from carros)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.