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. Sql Problem

Sql Problem

Scheduled Pinned Locked Moved Database
databasehelptutorial
4 Posts 4 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.
  • A Offline
    A Offline
    AhmedGebaly
    wrote on last edited by
    #1

    Id Credit Debit CurrentCredit Current Debit 51 21500 0 21500 0 52 0 21500 0 0 89 0 2150 0 2150 93 0 2140 0 4290 128 2140.5 0 0 2149.5 129 2151.5 0 2 0 171 0 1628 0 1626 190 1628 0 2 0 i have column of credit and debit and want to get columns of current credit and current debit example: 51. credit=21500 and debit=0 i have credit more than debit so this increase credit and decrease debit then current credit = 0+21500 52. credit=0 and debit=21500 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit =0 89 credit=0 and debit =2150 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit=0+2150=2150 93 credit=0 and debit =2140 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit=2140+2150= 4290 and so on...

    D K J 3 Replies Last reply
    0
    • A AhmedGebaly

      Id Credit Debit CurrentCredit Current Debit 51 21500 0 21500 0 52 0 21500 0 0 89 0 2150 0 2150 93 0 2140 0 4290 128 2140.5 0 0 2149.5 129 2151.5 0 2 0 171 0 1628 0 1626 190 1628 0 2 0 i have column of credit and debit and want to get columns of current credit and current debit example: 51. credit=21500 and debit=0 i have credit more than debit so this increase credit and decrease debit then current credit = 0+21500 52. credit=0 and debit=21500 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit =0 89 credit=0 and debit =2150 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit=0+2150=2150 93 credit=0 and debit =2140 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit=2140+2150= 4290 and so on...

      D Offline
      D Offline
      David Skelly
      wrote on last edited by
      #2

      That's very interesting. Is there a question in there?

      1 Reply Last reply
      0
      • A AhmedGebaly

        Id Credit Debit CurrentCredit Current Debit 51 21500 0 21500 0 52 0 21500 0 0 89 0 2150 0 2150 93 0 2140 0 4290 128 2140.5 0 0 2149.5 129 2151.5 0 2 0 171 0 1628 0 1626 190 1628 0 2 0 i have column of credit and debit and want to get columns of current credit and current debit example: 51. credit=21500 and debit=0 i have credit more than debit so this increase credit and decrease debit then current credit = 0+21500 52. credit=0 and debit=21500 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit =0 89 credit=0 and debit =2150 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit=0+2150=2150 93 credit=0 and debit =2140 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit=2140+2150= 4290 and so on...

        K Offline
        K Offline
        Kschuler
        wrote on last edited by
        #3

        Are you just looking for this? SELECT SUM(CurrentCredit) - SUM(CurrentDebit) AS FinalBalance FROM myTable

        1 Reply Last reply
        0
        • A AhmedGebaly

          Id Credit Debit CurrentCredit Current Debit 51 21500 0 21500 0 52 0 21500 0 0 89 0 2150 0 2150 93 0 2140 0 4290 128 2140.5 0 0 2149.5 129 2151.5 0 2 0 171 0 1628 0 1626 190 1628 0 2 0 i have column of credit and debit and want to get columns of current credit and current debit example: 51. credit=21500 and debit=0 i have credit more than debit so this increase credit and decrease debit then current credit = 0+21500 52. credit=0 and debit=21500 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit =0 89 credit=0 and debit =2150 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit=0+2150=2150 93 credit=0 and debit =2140 i have debit more than credit so this decrease credit and increase debit then current credit =0 and current debit=2140+2150= 4290 and so on...

          J Offline
          J Offline
          Jerry Hammond
          wrote on last edited by
          #4

          As interesting as your data is, what is your query?

          "My interest is in the future because I'm going to spend the rest of my life there." - Charles F. Kettering

          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