好吧,我知道這可能很難理解,隨意編輯它以便更有意義。基本上我想旋轉我的結果。我想選擇* from(從表中選擇col1,col2)tmp_table,但將tmp_table結果中的所有列作爲行。這裏是選擇將要tmp_table的:從另一個select中選擇列作爲每列的行
select
txt_description_1 label_1,
txt_description_2 label_2,
txt_description_3 label_3,
txt_description_4 label_4,
txt_description_5 label_5,
txt_description_6 label_6,
txt_description_7 label_7,
txt_description_8 label_8,
txt_description_9 label_9,
txt_description_10 label_10,
txt_description_11 label_11,
txt_description_12 label_12,
txt_description_13 label_13,
txt_description_14 label_14,
txt_description_15 label_15,
txt_description_16 label_16,
txt_description_17 label_17,
txt_description_18 label_18,
txt_description_19 label_19,
txt_description_20 label_20,
txt_description_21 label_21,
txt_description_22 label_22,
txt_description_23 label_23,
txt_description_24 label_24,
txt_description_25 label_25,
txt_description_26 label_26,
txt_description_27 label_27,
txt_description_28 label_28,
txt_description_29 label_29,
txt_description_30 label_30,
txt_description_31 label_31,
txt_description_32 label_32,
txt_description_33 label_33,
txt_description_34 label_34,
txt_description_35 label_35,
txt_description_36 label_36,
txt_description_37 label_37,
txt_description_38 label_38,
txt_description_39 label_39,
txt_description_40 label_40,
txt_description_41 label_41,
txt_description_42 label_42,
txt_description_43 label_43,
txt_description_44 label_44,
txt_description_45 label_45,
txt_description_46 label_46,
txt_description_47 label_47,
txt_description_48 label_48,
txt_description_49 label_49,
txt_description_50 label_50,
txt_description_51 label_51,
txt_description_52 label_52,
txt_description_53 label_53,
txt_description_54 label_54,
txt_description_55 label_55,
txt_description_56 label_56,
txt_description_57 label_57,
txt_description_58 label_58,
txt_description_59 label_59,
txt_description_60 label_60,
txt_info2 label_info2
from ngkbm_template_data_sets_
where practice_id = '0001'
and txt_data_set = @dataSet
and chk_label_values = 1
因此,可以說是輸出如下:
Protocol Test Dx Code Dx Test Code Interval Start Age Stop Age Gender NULL NULL Test Code (Medicare) Test Code (Medicare, Hish Risk) Interval (High Risk) Start Age (High Risk) Stop Age (High Risk) NULL NULL Seq # for Series Pre-Requisite Exam Pre-Requisite Exam Seq # Class NULL Other ID NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Set Info/Reference:
我想有它顯示是這樣的:
Protocol
Test
Dx Code
Dx
Test Code
INTERVAL
Start Age
Stop Age
Gender
NULL
NULL
我對於SSRS 2005也是這樣做的,所以這些限制適用。另外,select將僅返回一行,因此處理多行不是問題。
哇,這讓我感覺有點愚蠢。我一直在尋找這種過於複雜或超級優雅的解決方案,但像往常一樣,我只是讓它比需要的更困難。 – jreed121
現在我明白了。我改變了我對你說明的性能增益的查詢。 – jreed121