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

    Unanswered: Summing problems

    Hi
    I have tried 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 to do?

    sql = "SELECT SUM(area),landtype,place From databasetable where place='redden' GROUP BY landtype"


    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
    Mar 2004
    Posts
    52

    Re: Summing problems

    Originally posted by Td04
    Hi
    I have tried 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 to do?

    sql = "SELECT SUM(area),landtype,place From databasetable where place='redden' GROUP BY landtype"


    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
    **SOLVED**
    "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
  •