Results 1 to 3 of 3

Thread: Sum

  1. #1
    Join Date
    Nov 2003

    Unanswered: Sum

    Is there any way by which i can SUM only from a particular row to another particular row? For eg.

    BusNbr StopId EAT
    145 B01 0
    145 B02 5
    145 B03 6
    145 B04 2
    2 A01 0
    2 A02 2
    2 A03 4

    So now i only want to SUM the EAT from StopID=B02 to B04


  2. #2
    Join Date
    Oct 2003
    Manila, Philippines
    Yes it is very possible...

    this is how i am going to do the query:

    Select SUM(EAT) from yourTAble
    WHERE STOPID Between 'BO2' AND 'BO4'

    I cant distinguish what the diffence of using HAVING clause and WHERE here. Just try if it works.


  3. #3
    Join Date
    Jul 2003
    Penang, Malaysia
    maybe you should try something like this:

    select stopid, sum(eat)
    from table
    where stopdid like 'B0%'
    group by stopid

    No gurantee this statement would work,its a dry run, test it out at your side.

    Or you can dump your data into a temp table ( either virtual or non-virtual) , create an incremental identity column, and do a "between" statement.

    something like

    select sum(eat) from
    @virtualtable where virtualid
    between 1 and 10.
    Patrick Chua
    LBMS ( Learn By My Self) NPQ ( No paper Qualification )

Posting Permissions

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