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. Problem with simple SQL query :D

Problem with simple SQL query :D

Scheduled Pinned Locked Moved Database
helpdatabasesql-serversysadmin
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
    gamerPotatoe
    wrote on last edited by
    #1

    Hi there I'm playing around on SQL server 2000 and I get a error when i try to run this query: SELECT *, COUNT(P.PTICKETNO) AS counter from TICKETS_PURCHASED T,PASSENGER P WHERE P.PTICKETNO = T.TKTNO AND T.TKTNO = 'TKT000000000001' The error is as such. Column 'T.TKTNO' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause. What could be the problem guys . My SQL is very weak and I' just getting my feet wet, I would appreciate all the help :)

    M 1 Reply Last reply
    0
    • G gamerPotatoe

      Hi there I'm playing around on SQL server 2000 and I get a error when i try to run this query: SELECT *, COUNT(P.PTICKETNO) AS counter from TICKETS_PURCHASED T,PASSENGER P WHERE P.PTICKETNO = T.TKTNO AND T.TKTNO = 'TKT000000000001' The error is as such. Column 'T.TKTNO' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause. What could be the problem guys . My SQL is very weak and I' just getting my feet wet, I would appreciate all the help :)

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      Add a GROUP BY clause at the the end with the name of proper column and you will see that it will works. Look into GROUP BY in SQLServer Books Online for how to use it. Mazy You're face to face, With the man who sold the world - David Bowie

      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