2011-09-15 14 views
6

मैं इस बयान कि एक में एकाधिक पंक्तियों को जोड़ती है और फिर रास्ते में यह आउटपुट मैं डेटा की जरूरत है:ओरेकल अलग शीर्षक के साथ एक में एकाधिक पंक्तियों गठबंधन

SELECT COURSES_ID, REQUISITE_TYPE_TITLE 
      , RTRIM 
      (xmlagg (xmlelement (c, CONDITION_TITLE || '' || REQ_TEXT || '' ) order by ORDER_NUM).extract ('//text()') 
      , ',') AS REQTexts 
    FROM COS_REQUISITES 
    WHERE COURSES_ID = '1175' 
    AND REQUISITE_TYPE_TITLE != 'Corequisite' 
    GROUP BY COURSES_ID, REQUISITE_TYPE_TITLE; 

परिणाम:

╔═══════════╦════════════╦═════════════════════════════════════╦═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗ 
║ ORDER_NUM ║ COURSES_ID ║  REQUISITE_TYPE_TITLE   ║                                       REQ_TEXT                                       ║ 
╠═══════════╬════════════╬═════════════════════════════════════╬═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╣ 
║   1 ║  1175 ║ Limitation on Enrollment   ║ With minimum grade of "C"                                                                       ║ 
║   2 ║  1175 ║ Advisory on Recommended Preparation ║ MATH 200 or equivalent college course with "C" or better or equivalent college course with "C" or better or MATH 205 or equivalent college course with "C" or better or or equivalent college course with "C" or better or equivalent college course with "C" or better ║ 
╚═══════════╩════════════╩═════════════════════════════════════╩═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝ 

संरचना:

╔═══════════╦════════════╦═══════════╦═════════════════════════════════════╦══════════════════════════════════════════════════════════╗ 
║ ORDER_NUM ║ COURSES_ID ║ CONDITION ║  REQUISITE_TYPE_TITLE   ║       REQ_TEXT       ║ 
╠═══════════╬════════════╬═══════════╬═════════════════════════════════════╬══════════════════════════════════════════════════════════╣ 
║  1164 ║  1175 ║   ║ Advisory on Recommended Preparation ║ MATH 200 or equivalent college course with "C" or better ║ 
║  1165 ║  1175 ║   ║ Advisory on Recommended Preparation ║ or equivalent college course with "C" or better  ║ 
║  1166 ║  1175 ║ or  ║ Advisory on Recommended Preparation ║ MATH 205 or equivalent college course with "C" or better ║ 
║  1167 ║  1175 ║ or  ║ Advisory on Recommended Preparation ║ or equivalent college course with "C" or better  ║ 
║  1168 ║  1175 ║   ║ Advisory on Recommended Preparation ║ or equivalent college course with "C" or better  ║ 
║  1169 ║  1175 ║   ║ Limitation on Enrollment   ║ With minimum grade of "C"        ║ 
╚═══════════╩════════════╩═══════════╩═════════════════════════════════════╩══════════════════════════════════════════════════════════╝ 

वांटेड परिणाम:

╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗ 
║ Advisory on Recommended Preparation MATH 200 or equivalent college course with "C" or better or equivalent college course with "C" or better or MATH 205 or equivalent college course with "C" or better or equivalent college course with "C" or better or equivalent college course with "C" or better Limitation on Enrollment With minimum grade of "C" ║ 
╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝ 

मैं इसे एक अस्थायी तालिका या एकाधिक दृश्यों में रखने से बचने की कोशिश कर रहा हूं जो इसे एक सेक्शन में आउटपुट करेगा।

मुझे पता है कि इसमें खराब डेटा है लेकिन मुझे कचरा आउट, कचरा आउट बताया गया था। किसी भी तरह की सहायता का स्वागत किया जाएगा।

भी LISTAGG जो अलग के लिए जहाँ तक मैं बता सकता है की अनुमति नहीं है के साथ

:

चयन COURSES_ID, LISTAGG (REQUISITE_TYPE_TITLE || '' || CONDITION_TITLE || '' || REQ_TEXT, ' ') ग्रुप के भीतर ( ORDER_NUM द्वारा ऑर्डर) COS_REQUISITES से AS शीर्षक जहां COURSES_ID =' 1175 ' COURSES_ID द्वारा समूह;

परिणाम:

╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗ 
║                                                                TITLE                                                                ║ 
╠════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╣ 
║ Advisory on Recommended Preparation MATH 200 or equivalent college course with "C" or better Advisory on Recommended Preparation or equivalent college course with "C" or better Advisory on Recommended Preparation or MATH 205 or equivalent college course with "C" or better Advisory on Recommended Preparation or or equivalent college course with "C" or better Advisory on Recommended Preparation or equivalent college course with "C" or better Limitation on Enrollment With minimum grade of "C" ║ 
╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝ 

सूचना REQUISITE_TYPE_TITLE दोहराता, मैं सिर्फ यह चाहते थे परिणाम की तरह एक बार दिखाना चाहते हैं। मैं टेबल को संशोधित नहीं कर सकता क्योंकि यह एक टेबल है जिसे दैनिक रूप से लोड किया जा रहा है और रोज़ाना किसी और द्वारा अपडेट किया जाता है।

+3

वाह, pseudographics के लिए क्या पूछा! बहुत समय से मिले नहीं! (मेरे सुदूर प्रबंधक स्थापना के बाहर, वह है।) मैं दिखाऊंगा कि मैं एक उपयोगी, अच्छी तरह से लिखित और सचित्र प्रश्न +1 कर रहा हूं और इन सुंदर तालिकाओं को अकेले नहीं। :) –

+1

lol धन्यवाद ... मुझे यह लिंक करने के लिए यह लिंक उपयोगी पाया गया: http://www.sensefulsolutions.com/2010/10/format-text-as-table.html तो तालिका में एक्सेल को डेटा में कॉपी करें हेडर आदि। यूनिकोड कला और अपना काम चुनें। जैसा कि दिखाया गया है: http://webapps.stackexchange.com/questions/6700/is-there-a-webapp-to-create-ascii-art-tables और http://meta.stackexchange.com/questions/ 83009/do-you-know-any-online-tool-that-creates-ascii-table-for-use-use-on-stack-exc – AhsenB

+0

क्या एक अच्छा टूल है, धन्यवाद! –

उत्तर

1

थोड़ा गंदा लेकिन उपज चाहिए आप

SELECT 
COURSES_ID, 
RTRIM (xmlagg (xmlelement (c, REQUISITE_TYPE_TITLE || '' || REQTexts || '' ) order by mino).extract ('//text()'), ',') AS REQTexts 
FROM 
(
SELECT 
COURSES_ID, REQUISITE_TYPE_TITLE, MIN (ORDER_NUM) mino, 
RTRIM (xmlagg (xmlelement (c, CONDITION_TITLE || '' || REQ_TEXT || '' ) order by ORDER_NUM).extract ('//text()') , ',') AS REQTexts 
FROM COS_REQUISITES 
WHERE COURSES_ID = '1175' 
AND REQUISITE_TYPE_TITLE != 'Corequisite' 
GROUP BY COURSES_ID, REQUISITE_TYPE_TITLE 
) 
GROUP BY COURSES_ID; 
संबंधित मुद्दे