Jo, allt i ett
sql = "SELECT sum(tid) as totalruntid , sum(str) as totalstr , pass from traning where month(datum) = "& dMonth&" AND pass in ('run' ,'swim') group by pass"
1 svar · 182 visningar · startad av Johanneshov
Förslag på hur koden skall förenklas... hela sql-satsen i en rad kanske???
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/nyheter.mdb")
sql = "SELECT sum(tid) as totalruntid from traning where month(datum) = "& dMonth&" AND pass = 'run' "
sql2 = "SELECT sum(str) as totalrunstr from traning where month(datum) = "& dMonth&" AND pass = 'run' "
sql3 = "SELECT sum(tid) as totalswimtid from traning where month(datum) = "& dMonth&" AND pass = 'swim' "
sql4 = "SELECT sum(str) as totalswimstr from traning where month(datum) = "& dMonth&" AND pass = 'swim' "
Set rs1 = Conn.Execute (sql)
Set rs2 = Conn.Execute (sql2)
Set rs3 = Conn.Execute (sql3)
Set rs4 = Conn.Execute (sql4)
Response.Write "Total löptid: " & Int(rs1("totalruntid")/60) & ":" & Right("0" & (rs1("totalruntid") MOD 60), 2) &VbCrLf & "h."
response.write "<br>"
response.write "Sträcka löpning: " & rs2("totalrunstr") & " km"
response.write "<br>"
Response.Write "Total simtid: " &Int(rs3("totalswimtid")/60) & ":" & Right("0" & (rs3("totalswimtid") MOD 60), 2) &VbCrLf & "h."
response.write "<br>"
response.write "Sträcka simning: " & rs4("totalswimstr") & " km"
%>
<%
Set RS1 = Nothing
Set RS2 = Nothing
Set RS3 = Nothing
Set RS4 = Nothing
Conn.Close
Set Conn = Nothing
%>
Jo, allt i ett
sql = "SELECT sum(tid) as totalruntid , sum(str) as totalstr , pass from traning where month(datum) = "& dMonth&" AND pass in ('run' ,'swim') group by pass"