ORDER BY variabel.
Er det muligt at sortere på variabel som bliver sat til SUM?Her er min kode, og jeg har lavet det sådan at alt efter valg af ID som er links overskrift HTML, sorteres der på denne kolonne, det er normale udtræk.
Men jeg laver så en kolonne visning med variablen:
SumVariabel = conn.execute("SELECT SUM(hit_count) as TotalSum FROM hit_count_month_year WHERE page_name='" & Siden & "'")
som jeg viser og gerne ville kunne sortere på også, og det ved jeg ikke hvordan jeg gør?
<%
Select Case Request.querystring("ID")
Case "1"
ID="Order By page_name ASC"
Case "2"
ID="Order By Month_Number ASC, Year_Number ASC"
Case "3"
ID="Order By Year_Number DESC, hit_count DESC"
Case "4"
ID="Order By hit_count DESC, last_date DESC, last_time DESC"
Case "5"
ID="Order By last_date DESC, last_time DESC, hit_count DESC"
Case "6"
ID="Order By last_date DESC, last_time DESC, hit_count DESC"
Case "7"
Case Else
ID="Order By hit_count DESC, Month_Number, Year_Number ASC"
End Select
datavar = "select * from hit_count_month_year " & ID & ""
set nydata = conn.execute(datavar)
%>
<%Do while not nydata.EOF%>
<%
' Variabel til sidenavn i record
Siden=nydata("page_name")
' Variabel til side hits i record
SidenHits=nydata("hit_count")
' Variabel indeholder sum af klik paa side i record hit_count_month_year tabel
SumVariabel = conn.execute("SELECT SUM(hit_count) as TotalSum FROM hit_count_month_year WHERE page_name='" & Siden & "'")
' Variabel indeholder sum af klik total paa alle sider til sammen
TotalSumVariabel = conn.execute("SELECT SUM(hit_count) as AllTotalSum FROM hit_count_month_year")
%>
<% If Request.querystring("VisSti")=1 Then %>
<td><font face="Verdana" size="2"><a target="_blank" href=<%response.write(Siden)%>><%response.write(Siden)%></a> </font></td>
<% Else %>
<td><font face="Verdana" size="2"><a target="_blank" href=<%response.write(Siden)%>><%response.write(Mid(Siden,Int(InStrRev(Siden,"/",-1,0))+1,Len(Siden)-InStrRev(Siden,"/",-1,0)))%></a> </font></td>
<% End If %>
<td align="left"><font face="Verdana" size="2"><%response.write(MonthName(nydata("Month_Number"),True))%></font></td>
<td align="left"><font face="Verdana" size="2"><%response.write(nydata("Year_Number"))%></font></td>
<td align="left"><font face="Verdana" size="2"><%response.write(SidenHits)%></font></td>
<td align="left"><font face="Verdana" size="2"><%response.write(nydata("last_date"))%></font></td>
<td align="left"><font face="Verdana" size="2"><%response.write(nydata("last_time"))%></font></td>
<td align="left"><font face="Verdana" size="2"><%response.write(SumVariabel("TotalSum"))%></font></td>
<td align="center"><font face="Verdana" size="2"><%Response.Write(Round(SidenHits / GetDaysInMonth(nydata("Month_Number"),nydata("Year_Number")),1))%></font></td>
<td align="center"><font face="Verdana" size="2"><%Response.Write(Round(SumVariabel("TotalSum") / DateDiff("D",CountResat, (Date)),1))%></font></td>
<td align="center"><font face="Verdana" size="2"><%Response.Write(SidenHits)%></font></td>
<td align="center"><font face="Verdana" size="2"><%Response.Write(Round(SumVariabel("TotalSum") / DateDiff("M",CountResat, (Date)),1))%></font></td>
<td align="center"><font face="Verdana" size="2"><%Response.Write(Round(SumVariabel("TotalSum") / DateDiff("YYYY",CountResat, (Date)),1))%></font></td>
<td align="center"><font face="Verdana" size="2"><%Response.Write(Round((Int(SumVariabel("TotalSum")) * 100) / Int(SumTotalVariabel("AllTotalSum")),1))%></font></td>
</tr>
<%
nydata.movenext
loop
%>