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 can i add 2 querys from a select statement

How can i add 2 querys from a select statement

Scheduled Pinned Locked Moved Database
question
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.
  • U Offline
    U Offline
    User 1231056
    wrote on last edited by
    #1

    I have 2 select statements and both of them return a number, i need to add the result of both of them Does any one know HOW-TO do this... Glenn Guzman San Jose, Costa Rica

    C P 2 Replies Last reply
    0
    • U User 1231056

      I have 2 select statements and both of them return a number, i need to add the result of both of them Does any one know HOW-TO do this... Glenn Guzman San Jose, Costa Rica

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      SELECT A.A+B.B
      FROM (SELECT 1 as A) AS A
      INNER JOIN (SELECT 2 as B) AS B ON 1=1

      For this to work each subquery (the selects inside the brackets) must return exactly one row only.


      "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!

      1 Reply Last reply
      0
      • U User 1231056

        I have 2 select statements and both of them return a number, i need to add the result of both of them Does any one know HOW-TO do this... Glenn Guzman San Jose, Costa Rica

        P Offline
        P Offline
        Pradeep Shamarao
        wrote on last edited by
        #3

        U can try something like create view vwtest as select A.X S from Table A where union select B.X S from Table B where select sum(S) from vwtest cool man

        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