Subject | SQL Optimation best way |
---|---|

Author | checkmail |

Post date | 2015-11-04T13:41:30Z |

Hello @ll,

there are two tables

A

Field1

Field2

Field3

Field4

Field5

B

FieldA

FieldB

FieldC

Now I would like to get the following:

Sum(A.field3) where a.field1 = condition1 and a.field2 = condition2

In the same statement I would include

Sum(b.fieldc) where b.fielda = a.field4 and b.fieldb = a.field5

It is possible without cte?

For example: select sum(a.field3) from tablea a (select sum(b.fieldc) where b.fielda = a.field4 and b.fieldb = a.field5)

A.field1 and field2 are the intern project number, b.fielda and b.fieldb are the extern ordernumber year and number.

Thank you