<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SQL Teaser..easy points!! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620492#M925883</link>
    <description>How about&lt;BR /&gt;&lt;BR /&gt;select C1,C2,C3,max(C4)&lt;BR /&gt;from tablename&lt;BR /&gt;group by C1,C2,C3;&lt;BR /&gt;&lt;BR /&gt;/Jonas&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 28 Nov 2001 15:38:50 GMT</pubDate>
    <dc:creator>Jonas Linden</dc:creator>
    <dc:date>2001-11-28T15:38:50Z</dc:date>
    <item>
      <title>SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620484#M925875</link>
      <description>I have a table with say 4 columns C1, C2, C3 and C4.&lt;BR /&gt;Many records have identical values of C1, C2 and C3, but C4 may be different in each row. I want to do a "select unique C1, C2, C3 and any one C4, doesnt matter which one".&lt;BR /&gt;&lt;BR /&gt;For example, lets say my table has:&lt;BR /&gt;C1     C2     C3     C4&lt;BR /&gt;a       b        c       d&lt;BR /&gt;a       b        c       r&lt;BR /&gt;a       d        c       p&lt;BR /&gt;q       w       e       r&lt;BR /&gt;q       w       e       g&lt;BR /&gt;q       w       e       g&lt;BR /&gt;&lt;BR /&gt;I should get only 2 rows:&lt;BR /&gt;a    b    c    d/r/p&lt;BR /&gt;q    w    e    r/g&lt;BR /&gt;&lt;BR /&gt;Any guesses?</description>
      <pubDate>Tue, 27 Nov 2001 02:29:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620484#M925875</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2001-11-27T02:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620485#M925876</link>
      <description>select * from (table)&lt;BR /&gt;group by C1,C2,C3&lt;BR /&gt;order by C1,C2,C3&lt;BR /&gt;&lt;BR /&gt;would be what I would do, but I would get more than two rows.&lt;BR /&gt;&lt;BR /&gt;C1 C2 C3 C4&lt;BR /&gt;-----------&lt;BR /&gt;a  b  c  d&lt;BR /&gt;a  b  c  r&lt;BR /&gt;a  b  c  p&lt;BR /&gt;q  w  e  r&lt;BR /&gt;q  w  e  g</description>
      <pubDate>Tue, 27 Nov 2001 03:08:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620485#M925876</guid>
      <dc:creator>Josh Owings</dc:creator>
      <dc:date>2001-11-27T03:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620486#M925877</link>
      <description>Correction.  my sample output is incorrect given the "order by" statement, but the point was made.</description>
      <pubDate>Tue, 27 Nov 2001 03:11:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620486#M925877</guid>
      <dc:creator>Josh Owings</dc:creator>
      <dc:date>2001-11-27T03:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620487#M925878</link>
      <description>Thanks, but the requirement is to retrieve only 2 rows.&lt;BR /&gt;(with the distinct C1, C2 and C3).&lt;BR /&gt;Besides, I get an error saying that C4 must be listed in the group-by clause. (Informix Dynamic Server Version 7.31)</description>
      <pubDate>Tue, 27 Nov 2001 03:18:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620487#M925878</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2001-11-27T03:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620488#M925879</link>
      <description>I'm a bit rusty on my SQL, but I think you are looking for a function that take a list of rows and builds it into a single column / field. &lt;BR /&gt;&lt;BR /&gt;Have you looked for something like a 'crosstab' concept or using PL/SQL to programmatically create this?&lt;BR /&gt;&lt;BR /&gt;What database package are you using? &lt;BR /&gt;&lt;BR /&gt;Share and enjoy! Ian</description>
      <pubDate>Tue, 27 Nov 2001 11:22:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620488#M925879</guid>
      <dc:creator>Ian Dennison_1</dc:creator>
      <dc:date>2001-11-27T11:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620489#M925880</link>
      <description>I'm using Informix (IDS v7.31).&lt;BR /&gt;Well, I'm looking to this using pure SQL - even if it involves temp tables, outer joins and other such niceties.</description>
      <pubDate>Tue, 27 Nov 2001 14:11:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620489#M925880</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2001-11-27T14:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620490#M925881</link>
      <description>hummm....&lt;BR /&gt;&lt;BR /&gt;how about:&lt;BR /&gt;&lt;BR /&gt;select distinct c1,c2,c3 from tablename;&lt;BR /&gt;&lt;BR /&gt;???????&lt;BR /&gt;&lt;BR /&gt;...jcd...&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Nov 2001 22:26:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620490#M925881</guid>
      <dc:creator>Joseph C. Denman</dc:creator>
      <dc:date>2001-11-27T22:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620491#M925882</link>
      <description>Thanks jcd, but I need any one c4 as well.&lt;BR /&gt;(It should be one of the valid c4's. Otherwise I would have just done a "select unique c1, c2, c3, dummy as c4 from tablename")</description>
      <pubDate>Wed, 28 Nov 2001 02:10:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620491#M925882</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2001-11-28T02:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620492#M925883</link>
      <description>How about&lt;BR /&gt;&lt;BR /&gt;select C1,C2,C3,max(C4)&lt;BR /&gt;from tablename&lt;BR /&gt;group by C1,C2,C3;&lt;BR /&gt;&lt;BR /&gt;/Jonas&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Nov 2001 15:38:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620492#M925883</guid>
      <dc:creator>Jonas Linden</dc:creator>
      <dc:date>2001-11-28T15:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Teaser..easy points!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620493#M925884</link>
      <description>Brilliant!&lt;BR /&gt;Jonas, you have me kicking myself for not thinking of that earlier.&lt;BR /&gt;Thanks a ton to all who chipped in.</description>
      <pubDate>Thu, 29 Nov 2001 03:19:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-teaser-easy-points/m-p/2620493#M925884</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2001-11-29T03:19:29Z</dc:date>
    </item>
  </channel>
</rss>

