मेरे पास डेटाबेस का संबंध है और string_agg()
का उपयोग करना चाहूंगा क्योंकि यह मेरी ज़रूरत के अनुरूप है।
मैं चाहता हूँ:
string_agg कोई फ़ंक्शन दिए गए नाम से मेल नहीं खाता
product_id | quiz_id
-----------+----------
1 | 1,6
2 | 2,7
3 | 3,8
4 | 4
यहाँ मेरी डेटाबेस है।
select quiz_id , product_id, lastmodified from dugong.quiz;
quiz_id | product_id | lastmodified
---------+------------+-------------------------------
1 | 1 | 2015-11-11 14:46:55.619162+07
2 | 2 | 2015-11-11 14:46:55.619162+07
3 | 3 | 2015-11-11 14:46:55.619162+07
4 | 4 | 2015-11-11 14:46:55.619162+07
5 | 5 | 2015-11-11 14:46:55.619162+07
6 | 1 | 2015-11-11 14:46:55.619162+07
7 | 2 | 2015-11-11 14:46:55.619162+07
8 | 3 | 2015-11-11 14:46:55.619162+07
मेरे प्रयास:
दस्तावेज़ का संदर्भ लें। How to concatenate strings of a string field in a PostgreSQL 'group by' query? http://www.postgresql.org/docs/current/static/sql-expressions.html#SYNTAX-AGGREGATES
select product_id , string_agg(quiz_id, ',' order by lastmodified) from dugong.quiz;
ERROR: function string_agg(integer, unknown) does not exist
LINE 1: select product_id , string_agg(quiz_id, ',' order by lastmod...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Postgres संस्करण:
PostgresApp 9.4.4.1
अद्यतन:
@ कोड-भिक्षु यह अभी भी त्रुटि।
select product_id , string_agg(quiz_id::int, ',' order by lastmodified) from dugong.quiz;
ERROR: function string_agg(integer, unknown) does not exist
LINE 1: select product_id , string_agg(quiz_id::int, ',' order by la...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
प्रश्न:
क्या मेरी क्वेरी के साथ गलत क्या है?
ओह! आपका बहुत बहुत धन्यवाद। मैं दृश्य के पीछे तकनीकी के बारे में कभी नहीं जानता है। – Sarit
stackoverflow मुझे हरे रंग की जांच करने से पहले 4 मिनट प्रतीक्षा करें। एक क्षण प्रतीक्षा करें। :) – Sarit
ठीक है ... फिर स्वीकार करें :) –