Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Comparing values in a table

Comparing values in a table

Scheduled Pinned Locked Moved Database
helpdatabasesales
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DAAKH
    wrote on last edited by
    #1

    I don't have much knowledge in in programming and I need some help with this issue. I am using SQL 2005. I have a sales table in which I need to compare the difference in sales price of a house. Here is what the data would look like. ID SalePrice DateSale 2 90000 01/01/94 2 108500 05/12/04 2 115300 09/01/06 45 13500 03/01/54 45 98500 10/01/06 What I need, is a routine that would calulate one sale value from the preceeding for like ID. In the first case, there would be two resulting values calculated 18,500 and 6,800. These values would then be stored in a new table. I hope I have explained this well.

    Dale A. Young

    R 1 Reply Last reply
    0
    • D DAAKH

      I don't have much knowledge in in programming and I need some help with this issue. I am using SQL 2005. I have a sales table in which I need to compare the difference in sales price of a house. Here is what the data would look like. ID SalePrice DateSale 2 90000 01/01/94 2 108500 05/12/04 2 115300 09/01/06 45 13500 03/01/54 45 98500 10/01/06 What I need, is a routine that would calulate one sale value from the preceeding for like ID. In the first case, there would be two resulting values calculated 18,500 and 6,800. These values would then be stored in a new table. I hope I have explained this well.

      Dale A. Young

      R Offline
      R Offline
      Ritwik Sanyal
      wrote on last edited by
      #2

      Can you kindly examplify your input and output?

      D 1 Reply Last reply
      0
      • R Ritwik Sanyal

        Can you kindly examplify your input and output?

        D Offline
        D Offline
        DAAKH
        wrote on last edited by
        #3

        The example is simply a home sales table set up this way ID DateSale SaleAmount The table tracks all the sales that takes place in a community for the homes. A single home can be sold numerous times over its lifespan. So the challenges is to compare one sale amount to the next by date of sale. I need to calculate the difference between each sale and determine the % increase or decrease. I hope this helps.

        Dale A. Young

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups