pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bart Degryse <Bart.Degryse@indicator.be>
To: pgsql-sql@postgresql.org
Cc: Shavonne Marietta Wijesinghe <shavonne.marietta@studioform.it>
Subject: Re: Select and Count
Date: Tue, 20 Mar 2007 14:25:01 +0100
Message-ID: <45FFEEBD.A3DD.0030.0@indicator.be> (raw)
In-Reply-To: <Pine.LNX.4.64.0703200852180.25324@bugs.unl.edu.ar>
References: <005701c76ad8$8c4c7690$1102a8c0@dream>
	<Pine.LNX.4.64.07032008521 80.25324@bugs.unl.edu.ar>

Don't know any ASP but maybe Response.Write only accepts strings. In
that case you would need to do something like


<%
 Response.Write cStr(sch_sin)
%>

 

Maybe you can let the database do the summing: 

 

<% option explicit %>

<%

  Dim strSQL

  Dim oRs

  Dim oConn

  

  oConn = ... 'Fill this in for yourself

 

  strSQL = "SELECT COUNT(SCHE_SINGOLA) COU, SUM(SCHE_SINGOLA) SU FROM "
& MioTabella & " WHERE TRIM(date_inserted) >= '" & datainizio & "' AND
TRIM(date_inserted) <= '" & datafine & "'"

 
  oRs.open strSQL,oConn,3
 
  If oRs.RecordCount = 1 Then
    Response.Write(oRs("COU"))
    Response.Write(oRs("SU"))
  Else
    Response.Write("Something went wrong")
  End If
%>

>>> Martin Marques <martin@bugs.unl.edu.ar> 2007-03-20 12:55 >>>
On Tue, 20 Mar 2007, Shavonne Marietta Wijesinghe wrote:

> Hello
>
> I have a postgresql table and i do a select via ASP
>
> strSQL = "SELECT * FROM " & MioTabella & " WHERE TRIM(date_inserted)
>= '" & datainizio & "' AND TRIM(date_inserted) <= '" & datafine & "'"
>
> oRs.open strSQL,oConn,3
> schede = oRs.RecordCount
>
> Do until oRs.EOF
> sch_sin = cint(sch_sin) + cint(oRs("SCHE_SINGOLA").Value)
> oRs.movenext
> Loop

I know nothing about ASP, but it looks like you are doing a SUM of an
int 
with, maybe, an array (don't know how ASP defines oRs().Value output).

Keep in mind that you are pulling all the columns of that table (as you

used a * in the column selection).

Just a guess, nothing more then that.

--
  21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués         |   SELECT 'mmarques' ||
Centro de Telemática        |       '@' || 'unl.edu.ar';
Universidad Nacional        |   DBA, Programador,
     del Litoral             |   Administrador
---------------------------------------------------------
---------------------------(end of
broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

view thread (3+ messages)

Message-ID: <45FFEEBD.A3DD.0030.0@indicator.be>
Permalink:  ../45FFEEBD.A3DD.0030.0@indicator.be/
Also on:    postgresql.org/message-id/45FFEEBD.A3DD.0030.0@indicator.be

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Bart.Degryse@indicator.be, shavonne.marietta@studioform.it
  Subject: Re: Select and Count
  In-Reply-To: <45FFEEBD.A3DD.0030.0@indicator.be>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox