私はoracleにスクリプトを書きました。しかし、それは私に私が望む結果を与えるものではありません。 私はこれを必要とします、私は2つのテーブルがあると想像してください。 Order_tableとブックテーブル。 私の注文表は、この他のテーブルのテーブルの1つのフィールドを計算する
Select *
From (
Select Newtable.Counter As Value_id,
o.Id As Id,
o.Type_id As Type_id
From (
Select (Count B.Order_Type) As Counter,
B.Order_Type As Id
From Book B
Where B.Deleted = 'F'
Group By B.Order_Type
Order By Count(B.Order_Type) Desc
) newtable,
order_table o
where o.id = newtable.id
and o.type_id = 11
)
order by id asc;
結果はこのようなものですように私のスクリプトがあり、この
ORDER_TABLE表のように
ID TYPE_ID VALUE_ID
1 11 null
2 11 null
3 11 null
4 12 null
5 11 null
帳表
ID ORDER_TYPE DELETED
1 1 F
2 null F
3 5 F
4 5 F
5 4 F
6 4 F
7 3 T
です。
Value_ID TYPE_ID ID
2 11 5
2 11 4
1 11 1
2番目と3番目のIDに0カウントが表示されていません。カウントも表示できますか?
結果は次のようになります。
Value_ID TYPE_ID ID
2 11 5
2 11 4
1 11 1
0 11 2
0 11 3
order_tableとbook_tableの関係は何ですか? – Prathyush