{"id":445,"date":"2011-01-17T17:38:14","date_gmt":"2011-01-17T21:38:14","guid":{"rendered":"http:\/\/www.iowawebnet.com\/ein\/?p=445"},"modified":"2011-01-17T18:00:29","modified_gmt":"2011-01-17T22:00:29","slug":"calculating-total-from-recordset-using-select-case","status":"publish","type":"post","link":"https:\/\/www.iowawebnet.com\/ein\/2011\/01\/calculating-total-from-recordset-using-select-case\/","title":{"rendered":"Calculating total from recordset using &#8220;select case&#8221;"},"content":{"rendered":"<p><a rel=\"attachment wp-att-447\" href=\"http:\/\/www.iowawebnet.com\/ein\/?attachment_id=447\"><\/a><a rel=\"attachment wp-att-457\" href=\"http:\/\/www.iowawebnet.com\/ein\/?attachment_id=457\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-457\" title=\"Scholarship total score\" src=\"http:\/\/www.iowawebnet.com\/ein\/wp-content\/uploads\/2011\/01\/ScreenShot122.gif\" alt=\"total score\" width=\"532\" height=\"129\" srcset=\"https:\/\/www.iowawebnet.com\/ein\/wp-content\/uploads\/2011\/01\/ScreenShot122.gif 532w, https:\/\/www.iowawebnet.com\/ein\/wp-content\/uploads\/2011\/01\/ScreenShot122-300x72.gif 300w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/a><br \/>\n<strong>Here is code in classic asp<\/strong><\/p>\n<p>Here is example on how to calculate recordset total using &#8220;select case&#8221; statement. I have calculated essay and resume scholarship values based on records from\u00a0 two essay and resume tables, and queried results based on applicant-student registration ID or name. Then I calculated &#8220;total score&#8221; of each student using totals from two categories they were judged upon: essay and resume.<\/p>\n<blockquote><p>&lt;!DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&#8221;&gt;<\/p>\n<p>&lt;html xmlns=&#8221;http:\/\/www.w3.org\/1999\/xhtml&#8221;&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;&lt;\/title&gt;<br \/>\n&lt;link href=&#8221;Styles\/Site960.css&#8221; rel=&#8221;stylesheet&#8221; type=&#8221;text\/css&#8221; \/&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;%<br \/>\nDim objConn, objRS &#8216;\/conn str applicant tbl<br \/>\nDim objConnE, objRSE &#8216;\/conn str essay sum qry<br \/>\nDim objConnR, objRSR &#8216;\/conn str resume sum qry<br \/>\nDim SumEss, SumEss1, i_select, i_select2, count, countR<\/p>\n<p>SumEss = 0<br \/>\nSumEss1 = 0<br \/>\nSumRes = 0<br \/>\nSumRes1 = 0<br \/>\ncount = 0<br \/>\ncountR = 0<\/p>\n<p>&#8216; \/ open db conn &#8211; connopen \/<br \/>\nSet objConn = Server.CreateObject(&#8220;ADODB.Connection&#8221;)<br \/>\ndbPath = Server.MapPath(&#8220;scholarhip.accdb&#8221;)<br \/>\nobjConn.Open &#8220;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=&#8221; &amp; dbPath, &#8220;&#8221;, &#8220;&#8221;<br \/>\nSET objRS = Server.CreateObject(&#8220;ADODB.RecordSet&#8221;)<br \/>\nobjRS.Open &#8220;SELECT aName, sProgram FROM Applicants WHERE sProgram = &#8216;Incoming Freshmen&#8217; &#8220;,objConn,1,2<\/p>\n<p>Response.Write(&#8220;&lt;table class=&#8217;datagrid&#8217;&gt;&#8221;)<br \/>\nResponse.Write(&#8220;&lt;tr style=&#8217;background: #e1d6c7; font-weight: bold;&#8217;&gt;&#8221;)<br \/>\nResponse.Write(&#8220;&lt;td&gt;#&lt;\/td&gt;&lt;td&gt;Applicant&lt;\/td&gt;&lt;td&gt;Schol. Program&lt;\/td&gt;&lt;td&gt;Essay&lt;\/td&gt;&lt;td&gt;Resume&lt;\/td&gt;&lt;td&gt;Final Score&lt;\/td&gt;&#8221;)<br \/>\nResponse.Write(&#8220;&lt;\/tr&gt;&#8221;)<br \/>\nWhile not objRS.EOF<br \/>\ncountR = countR + 1<br \/>\nResponse.Write(&#8220;&lt;tr&gt;&#8221;)<br \/>\nResponse.Write(&#8220;&lt;td style=&#8217;text-align: right;&#8217;&gt;&#8221;&amp; countR &amp;&#8221;.&lt;\/td&gt;&#8221;)<br \/>\nResponse.Write(&#8220;&lt;td&gt;&#8221;&amp; objRS(&#8220;aName&#8221;) &amp;&#8221;&lt;\/td&gt;&#8221;)<br \/>\nResponse.Write(&#8220;&lt;td&gt;&#8221;&amp; objRS(&#8220;sProgram&#8221;) &amp;&#8221;&lt;\/td&gt;&#8221;)<br \/>\n&#8216;\/ total essay<br \/>\nResponse.Write(&#8220;&lt;td style=&#8217;text-align: right;&#8217;&gt;&#8221;)<br \/>\nSET objRSE = Server.CreateObject(&#8220;ADODB.RecordSet&#8221;)<br \/>\nobjRSE.Open &#8220;SELECT * FROM Essay WHERE Applicant='&#8221;&amp; objRS(&#8220;aName&#8221;)&amp;&#8221;&#8216; &#8220;,objConn,1,2<br \/>\nDim TotSum<br \/>\nWhile Not objRSE.EOF<br \/>\ncount = count + 1<br \/>\ni_select = Right(count,1)<br \/>\nselect case i_select<br \/>\ncase &#8220;1&#8221;,&#8221;3&#8243;,&#8221;5&#8243;,&#8221;7&#8243;,&#8221;9&#8243;<br \/>\nSumEss = ((objRSE(&#8220;Originality&#8221;))+(objRSE(&#8220;Clarity&#8221;))+(objRSE(&#8220;Content&#8221;))+(objRSE(&#8220;Neatness&#8221;))+(objRSE(&#8220;Grammar&#8221;))+(objRSE(&#8220;Punctuation&#8221;)))<br \/>\ncase &#8220;2&#8221;,&#8221;4&#8243;,&#8221;6&#8243;,&#8221;8&#8243;<br \/>\nSumEss1 = ((objRSE(&#8220;Originality&#8221;))+(objRSE(&#8220;Clarity&#8221;))+(objRSE(&#8220;Content&#8221;))+(objRSE(&#8220;Neatness&#8221;))+(objRSE(&#8220;Grammar&#8221;))+(objRSE(&#8220;Punctuation&#8221;)))<br \/>\nend select<br \/>\nobjRSE.MoveNext<br \/>\nWend<br \/>\nResponse.Write(FormatNumber((SumEss) + (SumEss1),0))<br \/>\nSET objRSE = Nothing<br \/>\n&#8216;objRSE.Close<br \/>\nResponse.Write(&#8220;&lt;\/td&gt;&#8221;)<\/p>\n<p>&#8216;\/ total resume<br \/>\nResponse.Write(&#8220;&lt;td style=&#8217;text-align: right;&#8217;&gt;&#8221;)<br \/>\nSET objRSR = Server.CreateObject(&#8220;ADODB.RecordSet&#8221;)<br \/>\nobjRSR.Open &#8220;SELECT * FROM Resume WHERE Applicant='&#8221;&amp; objRS(&#8220;aName&#8221;) &amp;&#8221;&#8216; &#8220;,objConn,1,2<br \/>\nDim TotSumR<br \/>\nWhile Not objRSR.EOF<br \/>\ncount2 = count2 + 1<br \/>\ni_select2 = Right(count2,1)<br \/>\nselect case i_select2<br \/>\ncase &#8220;1&#8221;,&#8221;3&#8243;,&#8221;5&#8243;,&#8221;7&#8243;,&#8221;9&#8243;<br \/>\nSumRes = ((objRSR(&#8220;Presentation&#8221;))+(objRSR(&#8220;Adherence&#8221;))+(objRSR(&#8220;Activities&#8221;))+(objRSR(&#8220;Potential&#8221;)))<br \/>\ncase &#8220;2&#8221;,&#8221;4&#8243;,&#8221;6&#8243;,&#8221;8&#8243;<br \/>\nSumRes1 = ((objRSR(&#8220;Presentation&#8221;))+(objRSR(&#8220;Adherence&#8221;))+(objRSR(&#8220;Activities&#8221;))+(objRSR(&#8220;Potential&#8221;)))<br \/>\nend select<br \/>\nobjRSR.MoveNext<br \/>\nWend<br \/>\nResponse.Write(FormatNumber((SumRes) + (SumRes1),0))<br \/>\nSET objRSR = Nothing<br \/>\nResponse.Write(&#8220;&lt;\/td&gt;&#8221;)<br \/>\nResponse.Write(&#8220;&lt;td style=&#8217;text-align: right;&#8217;&gt;&#8221;)<br \/>\nResponse.Write(FormatNumber((SumEss) + (SumEss1) + (SumRes) + (SumRes1),0))<br \/>\nResponse.Write(&#8220;&lt;\/td&gt;&#8221;)<br \/>\nResponse.Write(&#8220;&lt;\/tr&gt;&#8221;)<br \/>\nobjRS.MoveNext<br \/>\nWend<br \/>\n&#8216; close connections<br \/>\nSET objRS = nothing<br \/>\nSET objConn = nothing<\/p>\n<p>Response.Write(&#8220;&lt;\/table&gt;&#8221;)<\/p>\n<p>%&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Here is code in classic asp Here is example on how to calculate recordset total using &#8220;select case&#8221; statement. I have calculated essay and resume scholarship values based on records from\u00a0 two essay and resume tables, and queried results based on applicant-student registration ID or name. Then I calculated &#8220;total score&#8221; of each student using [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[30,35,34,36],"class_list":["post-445","post","type-post","status-publish","format-standard","hentry","category-classic-asp","tag-access-2","tag-calculation","tag-classic-asp-2","tag-total"],"_links":{"self":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/445"}],"collection":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":23,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"predecessor-version":[{"id":478,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/445\/revisions\/478"}],"wp:attachment":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}