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. SQL Help Required

SQL Help Required

Scheduled Pinned Locked Moved Database
databasehelp
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.
  • M Offline
    M Offline
    munklefish
    wrote on last edited by
    #1

    Hi, I need to retreive some info from an SQL2005 db, but am not knowledgeable in SQL to work out an efficient statement. Your help will be greatly appreciated. I need to retreive data for a given user(db_User) whilst counting info from a second column(db_Hours). However to make things a bit more difficult id like to count/sum all the (db_Hours) values as two named fields. The values of these named fields will be grouped according to a 3rd column(db_Valid) will either be 'yes', 'edit' or 'no'. SO in other words id like one statement (if possible) that will get me all the values of (db_Hours) for a named user, as two variables. One being the sume of all the 'db_Hours' where 'db_Valid' is equal to "yes", and a second where 'db_Valid' is not equal to 'yes'. I hope this makes sense, and that some kind person is able to help me out. Many Thanks guys! :sigh:

    K 1 Reply Last reply
    0
    • M munklefish

      Hi, I need to retreive some info from an SQL2005 db, but am not knowledgeable in SQL to work out an efficient statement. Your help will be greatly appreciated. I need to retreive data for a given user(db_User) whilst counting info from a second column(db_Hours). However to make things a bit more difficult id like to count/sum all the (db_Hours) values as two named fields. The values of these named fields will be grouped according to a 3rd column(db_Valid) will either be 'yes', 'edit' or 'no'. SO in other words id like one statement (if possible) that will get me all the values of (db_Hours) for a named user, as two variables. One being the sume of all the 'db_Hours' where 'db_Valid' is equal to "yes", and a second where 'db_Valid' is not equal to 'yes'. I hope this makes sense, and that some kind person is able to help me out. Many Thanks guys! :sigh:

      K Offline
      K Offline
      Kschuler
      wrote on last edited by
      #2

      Why don't you give a sample of the tables you are trying to pull from and the relevant fields that are in those tables. I'm guessing you are going to have a statemnet that will include a Group By clause and Sum function, but we can't create it for you without specifics. It may end up to be something like this: SELECT User, Valid, SUM(Hours) FROM MyTableName GROUP BY User, Valid

      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