Create a Unin Query Create a unin query t cmbine tw r mre queries int ne result set. Yu can cmbine queries that use different data surces. Fr example, yu can cmbine a query that returns data frm a dimensinal data surce with a query that returns data frm a relatinal data surce. T cmbine tw r mre queries, the fllwing cnditins must be met: The queries must have the same number f data items. The data items must have cmpatible types and appear in the same rder. Example - Create a Tw-clumn List Reprt fr Three Data Items Yu are a reprt authr at The Great Outdrs Cmpany, which sells sprting equipment. Yu are requested t create a list reprt that shws revenue fr all prduct lines, rder methds and sales territries. Hwever, yu want the prduct lines, rder methds and sales territries t appear in a single clumn. T create this reprt, yu use a unin query t jin the Prduct line, Order methd and Sales territry data items. Steps t Create a Reprt 1. Open Reprt Studi with the GO Sales (query) package. 2. In the Welcme dialg bx, click Create a new reprt r template. 3. In the New dialg bx, click Blank. 4. Pause the pinter ver the query explrer buttn and click Queries. 5. In the Insertable Objects pane, d the fllwing: Drag Query t the wrk area. Steps t Define the Queries Duble-click Query2. Drag Unin t the right f the query. Tw drp znes appear t the right f the peratr. Drag a Query bject t each drp zne. Drag a third Query bject just belw Query3 t include it in the Unin Query Query2, Query3 and Query4 are created in the wrk area, and a shrtcut t each query appears in the drp znes. 1. In the Insertable Objects pane, n the Surce tab, drag the fllwing data items t the Data Items 2. frm the Sales(Query) namespace pen the Prduct query subject and drag the Prduct line data item int Data Items pane. pen the Sales query subject, drag the Revenue data item int the Data Items pane. 1
3. In the Insertable Objects pane, n the Tlbx tab, drag Data Item t the Data Items pane. 4. The data item will be used t srt prduct lines and rder methds in the reprt. 5. In the Expressin Definitin bx, type 'A' and click OK. 6. In the Prperties pane, set the Name prperty t 7. Srt key 8. On the tlbar, press the back buttn t return t the Queries wrk area. Duble-click Query3. 1. In the Insertable Objects pane, n the Surce tab, drag the fllwing data items t the Data Items pen the Order methd query subject and drag Order methd int the Data Items pane. pen the Sales query subject and drag Revenue int the Data Items pane. 2. Repeat steps 3 t 5 t create a Srt key data item in Query3 with 'B' as its definitin. Duble-click Query4. 1. In the Insertable Objects pane, n the Surce tab, drag the fllwing data items t the Data Items pen the Sales staff query subject and drag Sales Regin int the Data Items pane. pen the Sales query subject and drag Revenue int the Data Items pane. 2. Repeat steps 3 t 5 t create a Srt key data item in Query4 with 'C' as its definitin. Steps t Define the Operatr 1. On the tlbar, press the back buttn t return t the Queries wrk area. 2. Click the Unin peratr. 3. Duble-click the Prjectin List prperty. The Prduct line item in the prjectin list cntains bth prduct lines and rder methds. 4. Click Manual. 5. Click Prduct line, and then click the edit buttn. 6. In the Edit bx, type the fllwing after Prduct line: 7. Click OK twice. Order methd & Sales regin Steps t Define the List Prperties 1. Duble-click Query1. 2. In the Insertable Objects pane, n the Surce tab, drag the fllwing data items t the Data Items Prduct line, Order methd & Sales regin Revenue Srt key 3. Select the Srt key data item and, in the Prperties pane, set the Pre-Srt prperty t Srt ascending. 2
When yu run the reprt, all prduct lines will appear first fllwed by all rder methds and then by all sales regins. 4. Pause the pinter ver the page explrer buttn and click Page1. 5. In the Insertable Objects pane, n the Tlbx tab, drag List t the wrk area. 6. Click the list. 7. Click the select ancestr buttn in the title bar f the Prperties pane and click List. 8. In the Prperties pane, set the Query prperty t Query1. The list is linked t the unin query. 9. Duble-click the Prperties prperty. 10. Select the Srt key check bx and click OK. Since the Srt key data item des nt appear in the list, yu must make it a prperty f the list befre it can srt prduct lines and rder methds. 11. In the Insertable Objects pane, n the Data Items tab, drag the fllwing items frm Query1 t the list: Prduct line, Order methd & Sales Regin Revenue 12. Run the reprt. A list reprt with tw clumns is prduced. All prduct lines, rder methds and sales regins appear in the first clumn. Steps t Add a Page Header and Fter t a Reprt Add a page header r fter when yu want infrmatin t appear n every page in the reprt, such as a title r page numbers. 1. T add a page header r fter, frm the Structure menu, click Headers & Fters, Page Header & Fter, select the apprpriate check bxes, and click OK. Tip: Yu can als click the headers & fters buttn n the tlbar. 2. Select the Header bject and use the Padding prperty t add a 10 pixel padding t the bttm f the Header. 3. Select the Fter bject and use the Padding prperty t add a 10 pixel padding t the tp f the Fter. 4. In the Insertable Objects pane, n the Tlbx tab, drag the Layut Cmpnent Reference bject t the Header. In the Cmpnent Lcatin bx and click Anther reprt, click the ellipsis (...) buttn. Navigate t Public Flders > Cgns Training -> Master Templates and Reprts > Page_Layut_Template_Pieces reprt. 5. In the Available cmpnents t reference bx, click the Prtrait_Header bject and click OK. 6. Select the Layut Cmpnent and in the Overrides prperty verride these named bjects: Header_Override1 3
7. Select OK. 8. In the Insertable Objects pane, n the Tlbx tab, drag the Text bject int the Drp item t verride child area f the header. Enter this text in the text bx: 9. Select OK Yur name s Reprt. 10. Repeat steps 4 thrugh 9 fr the Fter using the Prtrait_Fter bject in step 5 and the Fter_Override1 in Step 6. Replace the Yur name s Reprt text in the fter item with Sample Unin Query Reprt. 11. Select the Page Bdy and set the Fnt t Garamnd 8. 12. Select the Page Fter and set the Fnt t Garamnd 8. 13. Select the Page Fter and set the Fnt t Garamnd 7. 14. Run the reprt as a PDF. It shuld lk like this: Steps t finish frmatting the reprt. 1. In the Insertable Objects pane, click the Tlbx tab. 2. Drag a Table t the reprt. 4
The Insert Table dialg bx appears. 3. In the Number f clumns and Number f rws bxes, type the number f clumns (1) and rws (2) fr the table. 4. Select bth Table Cells and frm the Prperties Pane use the Padding prperty and apply a 5 pixel (5px) padding t all fur sides f the cell. Select OK. 5. Select the List bject and drag it int the bttm Table Cell. 6. Select the bttm Table Cell and set the Hrizntal Alignment frm the Prperties Pane t Center. 7. Select the tp Table Cell and set the Classes t Reprt Title Area. 8. In the Insertable Objects pane, click the Tlbx tab. 9. Drag the Text Item bject t the reprt. The Text dialg bx appears. 10. Type the text G Sales and Retailers and click OK. 11. Select the tp Table Cell and frm the Prperties Pane increase the Padding prperty n tp f the cell t 35 pixels (35px) and the bttm f the cell t 15 pixels (15px). Say OK. 12. Select the List Clumn Bdy fr the Prduct Line, Order Methd & Sales Regin Data Item. Use the Hrizntal Alignment frm the Prperties Pane t Left justify the cntents. 13. Run the reprt. It shuld lk like this: 5