Concatenate and group multiple rows in Oracle [duplicate]

Consider using LISTAGG function in case you’re on 11g: select grp, listagg(name,’,’) within group( order by name ) from name_table group by grp sqlFiddle upd: In case you’re not, consider using analytics: select grp, ltrim(max(sys_connect_by_path (name, ‘,’ )), ‘,’) scbp from (select name, grp, row_number() over (partition by grp order by name) rn from tab … Read more

how to apply group by on xslt elements

In XSLT 1.0, using Muenchian grouping. <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output method=”xml” indent=”yes” /> <xsl:key name=”division” match=”User” use=”@Division” /> <xsl:template match=”Users”> <AllUsers> <xsl:apply-templates select=”User[generate-id(.)=generate-id(key(‘division’,@Division)[1])]”/> </AllUsers> </xsl:template> <xsl:template match=”User”> <Division value=”{@Division}”> <xsl:for-each select=”key(‘division’, @Division)”> <User> <id><xsl:value-of select=”@id” /></id> <name><xsl:value-of select=”@name” /></name> </User> </xsl:for-each> </Division> </xsl:template> </xsl:stylesheet> In XSLT 2.0, use xsl:foreach-group <xsl:output method=”xml” indent=”yes” /> <xsl:template match=”Users”> … Read more

How do I group items in an array by date?

Here’s a solution using reduce. Split the time into a date string, and then set a key for each date. If the key exists push it onto the array: Update added the array format version const data = [ {notes: ‘Game was played’, time: ‘2017-10-04T20:24:30+00:00’, sport: ‘hockey’, owner: ‘steve’, players: ’10’, game_id: 1}, { notes: … Read more

Regex Group in Perl: how to capture elements into array from regex group that matches unknown number of/multiple/variable occurrences from a string?

my $string = “var1=100 var2=90 var5=hello var3=\”a, b, c\” var7=test var3=hello”; while($string =~ /(?:^|\s+)(\S+)\s*=\s*(“[^”]*”|\S*)/g) { print “<$1> => <$2>\n”; } Prints: <var1> => <100> <var2> => <90> <var5> => <hello> <var3> => <“a, b, c”> <var7> => <test> <var3> => <hello> Explanation: Last piece first: the g flag at the end means that you can … Read more

javascript | Object grouping

Reduce is great for situations like this. Given list below is your input data: const list = [{ ‘name’: ‘Display’, ‘group’: ‘Technical detals’, ‘id’: ’60’, ‘value’: ‘4’ }, { ‘name’: ‘Manufacturer’, ‘group’: ‘Manufacturer’, ‘id’: ’58’, ‘value’: ‘Apple’ }, { ‘name’: ‘OS’, ‘group’: ‘Technical detals’, ‘id’: ’37’, ‘value’: ‘Apple iOS’ } ]; const groups = list.reduce((groups, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)