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. redundant data

redundant data

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

    I'm trying to count data in a table. I was able to do it, however, when a data exists more than once, it shows it again and counts it again
    for example:
    column_name Count string 2 another string 1 same string 2
    This is my query:
    SELECT table_1, (SELECT COUNT(column_1) FROM Records as t1 WHERE t1.column_1 = table_1.column_1) AS Count FROM table_1
    Can anyone suggest an approach that would solve such redundancy? Thanks!

    A P 2 Replies Last reply
    0
    • H harcaype

      I'm trying to count data in a table. I was able to do it, however, when a data exists more than once, it shows it again and counts it again
      for example:
      column_name Count string 2 another string 1 same string 2
      This is my query:
      SELECT table_1, (SELECT COUNT(column_1) FROM Records as t1 WHERE t1.column_1 = table_1.column_1) AS Count FROM table_1
      Can anyone suggest an approach that would solve such redundancy? Thanks!

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      try this

      select distinct c1,count(c1) from table1 group by c1

      Bob Ashfield Consultants Ltd

      H 1 Reply Last reply
      0
      • A Ashfield

        try this

        select distinct c1,count(c1) from table1 group by c1

        Bob Ashfield Consultants Ltd

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

        oh shucks! stupid me! thanks! :)

        A 1 Reply Last reply
        0
        • H harcaype

          I'm trying to count data in a table. I was able to do it, however, when a data exists more than once, it shows it again and counts it again
          for example:
          column_name Count string 2 another string 1 same string 2
          This is my query:
          SELECT table_1, (SELECT COUNT(column_1) FROM Records as t1 WHERE t1.column_1 = table_1.column_1) AS Count FROM table_1
          Can anyone suggest an approach that would solve such redundancy? Thanks!

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Do use the distinct keyword as suggested by Mr. Ashfield :)

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

          1 Reply Last reply
          0
          • H harcaype

            oh shucks! stupid me! thanks! :)

            A Offline
            A Offline
            Ashfield
            wrote on last edited by
            #5

            No problem :-D

            Bob Ashfield Consultants Ltd

            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