N
N
neomichi2016-11-04 11:23:01
SQL
neomichi, 2016-11-04 11:23:01

How to write a query in sql with a calculated field?

there is entity A { id:int, title:string, numplaces:int, freenumplaces:int }
there is entity B { id:int, product:int, tikets:int}
tables are not related
when querying select "id", "title", "numplaces", "freenumplaces" from A
freenumplaces should count as (select Sum(tikets) from B where product= A .id)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2016-11-04
@neomichi

JOIN A with a selection from B pre-grouped by product

S
Sanan Yuzb, 2016-11-04
@Sanan07

You can use INSERT INTO to first insert data into this column, and then just SELECT to get everything from the table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question