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. how to compare an operation in where expression In sql

how to compare an operation in where expression In sql

Scheduled Pinned Locked Moved Database
databasetutorial
3 Posts 3 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.
  • G Offline
    G Offline
    GREG_DORIANcod
    wrote on last edited by
    #1

    hi everybody I need to do something like that:

    select x.ProductName, sum(x.field1+y.field2) as Mysum, y.field2 from tablexxx as x inner join tableyyy as y on x.id =y.id where as Mysum - y.field2 > 0

    obviously it doesnt work!, but I'm looking for suggestions

    S M 2 Replies Last reply
    0
    • G GREG_DORIANcod

      hi everybody I need to do something like that:

      select x.ProductName, sum(x.field1+y.field2) as Mysum, y.field2 from tablexxx as x inner join tableyyy as y on x.id =y.id where as Mysum - y.field2 > 0

      obviously it doesnt work!, but I'm looking for suggestions

      S Offline
      S Offline
      s_magus
      wrote on last edited by
      #2

      Something like this should do the trick.

      Select ProductName, MySum, field2
      From (Select x.ProductName, SUM(x.field1 + y.field2) as MySum, y.field2
      From tablexxx as x inner join
      tableyyy as y on x.id = y.id) as q
      Where MySum - field2 > 0

      1 Reply Last reply
      0
      • G GREG_DORIANcod

        hi everybody I need to do something like that:

        select x.ProductName, sum(x.field1+y.field2) as Mysum, y.field2 from tablexxx as x inner join tableyyy as y on x.id =y.id where as Mysum - y.field2 > 0

        obviously it doesnt work!, but I'm looking for suggestions

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Add Group By ProductName, Field2 after the where clause

        Never underestimate the power of human stupidity RAH

        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