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 calculate count?

How to calculate count?

Scheduled Pinned Locked Moved Database
databasehelptutorialquestion
2 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.
  • G Offline
    G Offline
    GroCareer
    wrote on last edited by
    #1

    Hi My Sql query is returing below resultset. SNO Id Count 1 101 2 102 3 104 4 102 5 106 6 102 7 104 I want if Id is repeating like 102 and 104 is repeating in above resulset .it should display count as: SNO Id Count 1 101 1 2 102 1 3 104 1 4 102 2 5 106 1 6 102 3 7 104 2 Please help how i write query for calculating clount value. Its urgent Plz help asap. Thanks

    H 1 Reply Last reply
    0
    • G GroCareer

      Hi My Sql query is returing below resultset. SNO Id Count 1 101 2 102 3 104 4 102 5 106 6 102 7 104 I want if Id is repeating like 102 and 104 is repeating in above resulset .it should display count as: SNO Id Count 1 101 1 2 102 1 3 104 1 4 102 2 5 106 1 6 102 3 7 104 2 Please help how i write query for calculating clount value. Its urgent Plz help asap. Thanks

      H Offline
      H Offline
      Harini N K
      wrote on last edited by
      #2

      Hi Try this: SELECT SNO, Id, ( SELECT (COUNT(*) + 1) FROM table1 b WHERE b.SNO < a.SNO AND a.Id = b.Id) FROM table1 a OR SELECT SNO, Id, ( SELECT COUNT(*) FROM table1 b WHERE b.SNO <= a.SNO AND a.Id = b.Id) FROM table1 a

      Harini

      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