Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2011
    Posts
    78

    Unanswered: Help with sum formula

    I have a column called Zone, there are different values in the column.

    Zone values: Brooklyn, NewYork, Queens, NewHaven, Woodburry

    For example, the value of NewYork is equal to NewYork+Queens. Queens is equal to Queens+NewYork.

    I am wondering how do I write this formula. Do I use the set function within the select statement?

  2. #2
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    Could you present schema and sample data, and expected result?
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

  3. #3
    Join Date
    Jul 2011
    Posts
    78
    SELECT [NETWORK]
    ,[CORP]
    ,[ZONE]
    ,[SUBS]
    FROM [ETT].[SUBCOUNTSPAGE]

    This is the table. In the Zone column, there are different values like I mentioned before.
    For example Zone: Brooklyn, NewYork, NewHaven,Queens, Woodburry
    Network: BBC,ANC, NBC,ANC,WAS
    Corp:1233,1234,5456,2341,1234
    Subs:14,10,15,51,12

    I want the derive values from the sub column and get new values based on the formula NewYork1 is equal to NewYork+Queens

    For example, the value in the Network column ANC for NewYork is 10 and the value in the Network column ANC for Queens is 15. I wanted to show that Newyork1=25 in a new column.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    what you just wrote might make sense to you but it makes no sense to us

    please give several rows of actual data, and then show what results you want for those rows
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jul 2011
    Posts
    78
    NETWORK CORP ZONE SUBS DATETIMESTAMP
    AEC 7862 Hudson 51603 1108
    MMC 862 Hudson 51603 1108
    AEC 7804 Bayonne 14879 1108
    MMC 7804 Bayonne 14879 1108


    These are actual data in one table. I want to be able to add AEC in Hudson and MMC in Hudson to equal to AEC1. The new value would be 51603+14879 in a new column. I have to do this for every zone and the formulas are all different.

    My approach is to do one zone at a time. I separate the Hudson and Bayonne zones in to different views. From there, I guess I have to some how add the subs together.

    Please let me know if this make more sense and if you have any idea.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Mangolili View Post
    I want to be able to add AEC in Hudson and MMC in Hudson to equal to AEC1. The new value would be 51603+14879 in a new column.
    "to equal to AEC1" doesn't make sense

    and "51603+14879 in a new column" might make sense, if you defined the new column first

    i really don't think i am going to be able to understand what you want, even if i keep asking, so i'm going to bow out and let someone else take a crack at it
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Jul 2011
    Posts
    78
    sorry for the confusions, I kind of figured it out. I separate my data and make them into different views. Then I going to add them together as columns and make it equal to a new column.

Posting Permissions

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