Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    52

    Question Unanswered: Summing Problems

    I have try to make multiple summatings from a oracle database with a ASP page.
    But I got stuck withe the SQL statements.
    I have 3 columns of interest. place area and landtype.
    I would like to do all the summating in a single SLQ statemet.
    And I want to get a result as if I coose the place redden
    I get as a result
    grass area = 10
    water area = 15
    farmland = 20
    and so on.

    I tried sth like below without success.
    Is it possible or should one use some kind of group statement?

    sql = "SELECT SUM(area) AS [grass]From databasetable where landtype='grass' AND place = 'redden' AND SUM(area) AS [water]From databasetable where landtype='water' AND place = 'redden' AND SUM(area) AS [farmland]From databasetable where landtype='farmland' AND place = 'redden'"

    and then print out the recordsets as
    <%
    rs.movefirst
    do while not rs.eof
    %>
    <TR>
    <TD><%=rs("grass")%>
    </TR>
    <TR>
    <TD><%=rs("water")%>
    </TR>
    <TR>
    <TD><%=rs("farmland")%>
    </TR>
    <%
    rs.movenext
    loop
    %>

    Thanks//Martin
    "Never underestimate a large number of morons"

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Hmmm, I could give you a method of doing this in MS SQL but not in Oracle I'm sorry.... and I'm pretty sure the MS SQL solution would not work in Oracle,... I would suggest posting a question in the Oracle forums and seeing if anyone can help with the SQL there...

  3. #3
    Join Date
    Mar 2004
    Posts
    52
    Originally posted by rokslide
    Hmmm, I could give you a method of doing this in MS SQL but not in Oracle I'm sorry.... and I'm pretty sure the MS SQL solution would not work in Oracle,... I would suggest posting a question in the Oracle forums and seeing if anyone can help with the SQL there...
    How do I get the results printed out in the asp page?
    the sum and so on
    Do I get multiple Sums if I write like below and use group by?

    select sum(column) AS RECORDSET

    Thanks//Martin
    "Never underestimate a large number of morons"

  4. #4
    Join Date
    Mar 2004
    Posts
    52
    I got it resolved...
    "Never underestimate a large number of morons"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •