Forums
This topic is locked
help with SELECT MAX
Posted 02 Jul 2005 08:30:23
1
has voted
02 Jul 2005 08:30:23 Jaime Romo posted:
hello there i have a table with 3 fileds id, puntuacion, imagei need to display the one that has been more clicked
i use the select max but it only displays the puntuacion field
how can i displays all the filds
thanks
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_smaDBN2_STRING
Recordset1.Source = "SELECT MAX(puntuacion) FROM smaDBreventonVOTACION"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
Visit my home page
www.cancuncoral.com
Replies
Replied 03 Jul 2005 01:28:24
03 Jul 2005 01:28:24 Rene Bandsma replied:
Maybe you should use the GROUP BY function?
<hr><b>DMXZone support manager</b><br><a href="www.kousman.nl">Kousman web resellers</a>
<hr><b>DMXZone support manager</b><br><a href="www.kousman.nl">Kousman web resellers</a>
Replied 03 Jul 2005 06:03:28
03 Jul 2005 06:03:28 Jaime Romo replied:
thanks for your reply but does the group by will retunrn me the biggers numer on the table???
Visit my home page
www.cancuncoral.com
Visit my home page
www.cancuncoral.com
Replied 03 Jul 2005 08:36:11
03 Jul 2005 08:36:11 Jaime Romo replied:
i have a problme with this
i trayed to use select MAX and group by but i cluldent make it work so i use order BY
Recordset1.Source = "SELECT * FROM smaDBreventonVOTACION ORDER BY puntuacion DESC"
the problem is when i have to many records it does not sort by descending o ascending.... any idea what is the problem
Visit my home page
www.cancuncoral.com
i trayed to use select MAX and group by but i cluldent make it work so i use order BY
Recordset1.Source = "SELECT * FROM smaDBreventonVOTACION ORDER BY puntuacion DESC"
the problem is when i have to many records it does not sort by descending o ascending.... any idea what is the problem
Visit my home page
www.cancuncoral.com
Replied 14 Jul 2005 16:46:23
14 Jul 2005 16:46:23 myke black replied:
You do not need to use group by if selecting a max value from a single table, what you do need to do is give the returned recordset a name for your max field like this:
<pre id=code><font face=courier size=2 id=code>
SELECT MAX(puntuacion) as maxNumber FROM smaDBreventonVOTACION
</font id=code></pre id=code>
You can reference this field with:
<pre id=code><font face=courier size=2 id=code>
maxNumber = Recordset1.fields("maxNumber"
</font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code>
SELECT MAX(puntuacion) as maxNumber FROM smaDBreventonVOTACION
</font id=code></pre id=code>
You can reference this field with:
<pre id=code><font face=courier size=2 id=code>
maxNumber = Recordset1.fields("maxNumber"
</font id=code></pre id=code>