Home > database >  Oracle SQL queries
Oracle SQL queries

Time:10-06

Now I built a few table
Industry table T_INDUSTRY
INDUSTRY_ID INDUSTRY_NAME
1 steel
2 cement
3 aluminium
4 shipbuilding
5 flat glass
. .



Bond holdings table T_HLD
Bond ID the name of the bond issuer position denomination
C_ID C_NAME ISSUER_ID ISSUER_NAME INvEST_AMOUNT
1 corporate 100 a, 100 a company
2 the convertible bond 101 bb company 200


Publisher industry table T_COMPANY_INDUSTRY
Publisher industry ID
ISSUER_ID INDUSTRY_ID
100 1
101 2

There is also a schedule, a financial plan inside can have multiple bond

Now I want to check out the results
Electrolytic aluminium shipbuilding steel cement plate glass...
Plan 1 100 XXX XXX
Plan 2 XXX 200
.


Longitudinal financial planning is a dynamic LIst, transverse industry also to dynamic change, because the industry is also will update, how to use a SQL query out the result?




CodePudding user response:

A statement that don't come, you can use dynamic statement, store the results in the table in the middle, then the query table in the middle

CodePudding user response:

Electrolytic aluminium shipbuilding steel cement plate glass...

The above content, did you come from?

Suggest you post some test data, and your expected results;

CodePudding user response:

 select 'plans' | | rownum financial planning, 
B.I SSUER_ID,
Max (case when Anderson NDUSTRY_NAME='steel' then b.I NvEST_AMOUNT end) steel,
Max (case when Anderson NDUSTRY_NAME='cement then b.I NvEST_AMOUNT end) cement,
Max (case when Anderson NDUSTRY_NAME='aluminium then b.I NvEST_AMOUNT end) electrolytic aluminum,
Max (case when Anderson NDUSTRY_NAME='shipbuilding then b.I NvEST_AMOUNT end) shipbuilding,
Max (case when Anderson NDUSTRY_NAME='flat glass then b.I NvEST_AMOUNT end) flat glass
The from T_INDUSTRY a, T_HLD b, T_COMPANY_INDUSTRY c, finance schedule d
Where Anderson NDUSTRY_ID=c.I NDUSTRY_ID
And b.I SSUER_ID=c.I SSUER_ID
And biggest _ID=, dc _ID
Group by b.I SSUER_ID;

CodePudding user response:

Top a...
  • Related