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 count multiselected queries

how to count multiselected queries

Scheduled Pinned Locked Moved Database
databasetutorialquestion
4 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.
  • H Offline
    H Offline
    harcaype
    wrote on last edited by
    #1

    Is it possible to count rows with a multi-selected query? I have no problems counting in one table however, my real goal is to count rows of mutiple tables.
    Here's a sample. This counts for one table SELECT COUNT(*) FROM table_1 WHERE condition
    And what I want is to count this multiselected one: SELECT table_1.column1,table_2.column4,table_3.column7 FROM table_1,table_2,table_3 WHERE condition
    Do you know how to count the rows of this one? Is it possible? Thanks!

    B 1 Reply Last reply
    0
    • H harcaype

      Is it possible to count rows with a multi-selected query? I have no problems counting in one table however, my real goal is to count rows of mutiple tables.
      Here's a sample. This counts for one table SELECT COUNT(*) FROM table_1 WHERE condition
      And what I want is to count this multiselected one: SELECT table_1.column1,table_2.column4,table_3.column7 FROM table_1,table_2,table_3 WHERE condition
      Do you know how to count the rows of this one? Is it possible? Thanks!

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      SELECT table_1.column1, (select count(*) from table1 as t1 where t1.col = table_1.col) as CountTable1, table_2.column4, (select count(*) from table2 as t2 where t2.col = table_2.col) as CountTable2, table_3.column7 (select count(*) from table3 as t3 where t3.col = table_3.col) as CountTable3 FROM table_1,table_2,table_3 WHERE condition


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

      H 1 Reply Last reply
      0
      • B Blue_Boy

        SELECT table_1.column1, (select count(*) from table1 as t1 where t1.col = table_1.col) as CountTable1, table_2.column4, (select count(*) from table2 as t2 where t2.col = table_2.col) as CountTable2, table_3.column7 (select count(*) from table3 as t3 where t3.col = table_3.col) as CountTable3 FROM table_1,table_2,table_3 WHERE condition


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

        H Offline
        H Offline
        harcaype
        wrote on last edited by
        #3

        I GOT IT! Thanks! :)

        B 1 Reply Last reply
        0
        • H harcaype

          I GOT IT! Thanks! :)

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          No problem.


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

          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