データベースからのデータを「スプレッドシート」タイプの方法で表示する必要があります。通常の場合のように、値は行として水平に表示されるのではなく、垂直に表示されます。
グリッドは、正確に 16 列 x 12 行である必要があります。通常のシナリオでは、最大 96 行の 2 列になります。
ClearLogic の回答から得たクエリは次のとおりです。
2 つの長い列をいくつかの列のペアに分割する SQL ステートメントはありますか?
..非常に近いですが、15 列を生成し、いくつかの値を 2 回追加しています。この道を進みたいと思わせるほど近くに見えます。
注: Val1 は常に 1 ~ 96 の値です。
私のSQL(16列×15行の結果セットを生成する)は次のとおりです。
Select Val1 AS col1, Val2 AS col2,NULL AS Col3,NULL AS Col4 ,NULL AS
Col5,NULL AS Col6,NULL AS col7,NULL AS Col8, NULL AS Col9, NULL AS Col10, NULL AS
Col11, NULL AS Col12, NULL AS Col13, NULL AS Col14, NULL AS Col15, NULL AS Col16
from PLATYPUSAVAILABILITY where Val1 < 13 and PLATYPUSID = 42
AND AVAILABLEDATE = to_date('20120823', 'yyyymmdd')
UNION select NULL AS col1,NULL AS col2,Val1 AS Col3, Val2 AS Col4,NULL
AS Col5,NULL AS Col6,NULL AS col7,NULL AS Col8, NULL AS Col9, NULL AS Col10, NULL AS
Col11, NULL AS Col12, NULL AS Col13, NULL AS Col14, NULL AS Col15, NULL AS Col16
from PLATYPUSAVAILABILITY where Val1 > 12 and Val1 < 25 and
PLATYPUSID = 42 AND AVAILABLEDATE = to_date('20120823', 'yyyymmdd')
UNION select NULL AS col1,NULL AS col2 ,NULL AS Col3, NULL AS Col4,Val1 AS
Col5, Val2 AS Col6,NULL AS col7,NULL AS Col8, NULL AS Col9, NULL AS Col10, NULL
AS Col11, NULL AS Col12, NULL AS Col13, NULL AS Col14, NULL AS Col15, NULL AS Col16
from PLATYPUSAVAILABILITY where Val1 > 24 and Val1 < 37 and
PLATYPUSID = 42 AND AVAILABLEDATE = to_date('20120823', 'yyyymmdd')
UNION select NULL AS col1,NULL AS col2 ,NULL AS Col3, NULL AS Col4, NULL AS
Col5, NULL AS Col6,Val1 AS col7,Val2 AS Col8, NULL AS Col9, NULL AS
Col10, NULL AS Col11, NULL AS Col12, NULL AS Col13, NULL AS Col14, NULL AS Col15,
NULL AS Col16 from PLATYPUSAVAILABILITY where Val1 > 36 and Val1
< 49 and PLATYPUSID = 42 AND AVAILABLEDATE = to_date('20120823', 'yyyymmdd')
UNION select NULL AS col1,NULL AS col2 ,NULL AS Col3, NULL AS Col4,Val1 AS
Col5,Val2 AS Col6,NULL AS col7,NULL AS Col8, Val1 AS Col9, Val2 AS
Col10, NULL AS Col11, NULL AS Col12, NULL AS Col13, NULL AS Col14, NULL AS Col15,
NULL AS Col16 from PLATYPUSAVAILABILITY where Val1 > 48 and Val1
< 61 and PLATYPUSID = 42 AND AVAILABLEDATE = to_date('20120823', 'yyyymmdd')
UNION select NULL AS col1,NULL AS col2 ,NULL AS Col3, NULL AS Col4,NULL AS
Col5,NULL AS Col6,NULL AS col7,NULL AS Col8, NULL AS Col9, NULL AS Col10,
Val1 AS Col11, Val2 AS Col12, NULL AS Col13, NULL AS Col14, NULL AS
Col15, NULL AS Col16 from PLATYPUSAVAILABILITY where Val1 > 60 and
Val1 < 73 and PLATYPUSID = 42 AND AVAILABLEDATE = to_date('20120823', 'yyyymmdd')
UNION select NULL AS col1,NULL AS col2 ,NULL AS Col3, NULL AS Col4,NULL AS
Col5,NULL AS Col6,NULL AS col7,NULL AS Col8, NULL AS Col9, NULL AS Col10, NULL AS
Col11, NULL AS Col12, Val1 AS Col13, Val2 AS Col14, NULL AS Col15, NULL
AS Col16 from PLATYPUSAVAILABILITY where Val1 > 72 and Val1 < 85
and PLATYPUSID = 42 AND AVAILABLEDATE = to_date('20120823', 'yyyymmdd')
UNION select NULL AS col1,NULL AS col2 ,NULL AS Col3, NULL AS Col4,NULL AS
Col5,NULL AS Col6,NULL AS col7,NULL AS Col8, NULL AS Col9, NULL AS Col10, NULL AS
Col11, NULL AS Col12, NULL AS Col13, NULL AS Col14, Val1 AS Col15, Val2
AS Col16 from PLATYPUSAVAILABILITY where Val1 > 84 and PLATYPUSID = 42
AND AVAILABLEDATE = to_date('20120823', 'yyyymmdd')
15行にオーバーフローするのではなく、12行に制限するにはどうすればよいですか?
TOAD でこのクエリを実行した後に表示されるスクリーン ショットは、次の場所で見ることができます。
http://warbler.posterous.com/so-close-and-yet-so-far-away-sqlizers-lament
行数は 12 行のみで、値は列 9 と 10 の先頭から始まり、列 11 と 12 の 1 つの行 (一番上の行) にオーバーフローする必要があります。
Datagridview をタグとして使用しました。これは、このデータが最終的に向かう場所であるためです。
アップデート
動作しました。DataGridView に交互の垂直列を設定することは可能ですか? を参照してください。