<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-AU;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Brilliant - now works - Many thanks Pierma!<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Pierre-Marie Le Dantec [mailto:pierremarie.ledantec@gmail.com] <br><b>Sent:</b> Thursday, 31 March 2016 7:17 AM<br><b>To:</b> Phil (The Geek) Wyatt<br><b>Cc:</b> Qgis-user@lists.osgeo.org<br><b>Subject:</b> RE: [Qgis-user] Selecting records<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p>Do tou have an error or result is not as expected ?<br>If qgis complains about sql query or invalid layer, it can be because i forgot fields calculated through a function need to be explicitly named:<o:p></o:p></p><p>SELECT stationid, MAX(obs_date) AS max_date FROM your_layer GROUP BY stationid<o:p></o:p></p><p>This should works on any valid layer. Tested successfully with a GeoJSON layer.<o:p></o:p></p><p>Pierma<o:p></o:p></p><div><p class=MsoNormal>Le 30 mars 2016 21:19, "Phil (The Geek) Wyatt" <<a href="mailto:phil@wyatt-family.com">phil@wyatt-family.com</a>> a écrit :<o:p></o:p></p><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Alas, this doesn't seem to work on the GEOJSON linked layer</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Pierre-Marie Le Dantec [mailto:<a href="mailto:pierremarie.ledantec@gmail.com" target="_blank">pierremarie.ledantec@gmail.com</a>] <br><b>Sent:</b> Wednesday, 30 March 2016 3:59 PM<br><b>To:</b> Phil (The Geek) Wyatt<br><b>Cc:</b> <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br><b>Subject:</b> Re: [Qgis-user] Selecting records</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><div><div><div><div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>Hi Phil,<o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>For manipulating dates throught SQL you should use ISO format ("YYYY-MM-DD").<o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>Then, you can use a virtual layer with :<o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>SELECT stationid, MAX(obs_date) FROM your_layer GROUP BY stationid<o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>Cheers,<o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Pierma<o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>2016-03-30 13:09 GMT+11:00 Phil (The Geek) Wyatt <<a href="mailto:phil@wyatt-family.com" target="_blank">phil@wyatt-family.com</a>>:<o:p></o:p></p><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I must be thick, but I can't get my head around this in QGIS<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Data<o:p></o:p></p><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=139 style='width:104.0pt;border-collapse:collapse'><tr style='height:15.0pt'><td width=64 nowrap valign=bottom style='width:48.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:black'>stationid_</span><o:p></o:p></p></td><td width=75 nowrap valign=bottom style='width:56.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:black'>obs_date</span><o:p></o:p></p></td></tr><tr style='height:15.0pt'><td width=64 nowrap valign=bottom style='width:48.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:black'>BK21</span><o:p></o:p></p></td><td width=75 nowrap valign=bottom style='width:56.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right'><span style='color:black'>28/03/2016</span><o:p></o:p></p></td></tr><tr style='height:15.0pt'><td width=64 nowrap valign=bottom style='width:48.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:black'>BK21</span><o:p></o:p></p></td><td width=75 nowrap valign=bottom style='width:56.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right'><span style='color:black'>29/03/2016</span><o:p></o:p></p></td></tr><tr style='height:15.0pt'><td width=64 nowrap valign=bottom style='width:48.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:black'>BK21</span><o:p></o:p></p></td><td width=75 nowrap valign=bottom style='width:56.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right'><span style='color:black'>30/03/2016</span><o:p></o:p></p></td></tr><tr style='height:15.0pt'><td width=64 nowrap valign=bottom style='width:48.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:black'>BL22</span><o:p></o:p></p></td><td width=75 nowrap valign=bottom style='width:56.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right'><span style='color:black'>28/03/2016</span><o:p></o:p></p></td></tr><tr style='height:15.0pt'><td width=64 nowrap valign=bottom style='width:48.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:black'>BL22</span><o:p></o:p></p></td><td width=75 nowrap valign=bottom style='width:56.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right'><span style='color:black'>29/03/2016</span><o:p></o:p></p></td></tr><tr style='height:15.0pt'><td width=64 nowrap valign=bottom style='width:48.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:black'>BL22</span><o:p></o:p></p></td><td width=75 nowrap valign=bottom style='width:56.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right'><span style='color:black'>30/03/2016</span><o:p></o:p></p></td></tr><tr style='height:15.0pt'><td width=64 nowrap valign=bottom style='width:48.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:black'>BL22</span><o:p></o:p></p></td><td width=75 nowrap valign=bottom style='width:56.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.0pt'><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right'><span style='color:black'>31/03/2016</span><o:p></o:p></p></td></tr></table><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>How do I select the Maximum date for each station ID?<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>The data will be coming from a GEOJSON feed but I can also pull it as a shape file if needs be<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Cheers - Phil<o:p></o:p></p></div></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><br>_______________________________________________<br>Qgis-user mailing list<br><a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><br><br clear=all><br>-- <o:p></o:p></p><div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Pierre-Marie Le Dantec<br><br>73.64.34<o:p></o:p></p></div></div></div></div></div></div></div></div></div></body></html>