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. Query Help

Query Help

Scheduled Pinned Locked Moved Database
helpquestiondatabasecareer
3 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
    Hulicat
    wrote on last edited by
    #1

    I have the following query that works, however; I need add another field "client_id" that I need to tie to client name in another table. I can't even add the client_id from the job_tickets table with this error: "select coMsg 8120, Level 16, State 1, Line 1 Column 'job_ticket.CLIENT_ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause." I need to display the "client_name" feild from "Clients" table that based off of dbo.job_tickets.client_id...I can do another inner join in the below starement? How do I achieve this? This works....I just to add the aforementioned select count(job_ticket_id) as 'Total', problem_type.problem_type_name 'Problem Type' from job_ticket inner join problem_type on dbo.problem_type.problem_type_id = job_ticket.problem_type_id where report_date between '1/01/2007' and '1/31/2007' group by problem_type.PROBLEM_TYPE_NAME any help is greatly appreciated.

    Regards, Hulicat

    C 1 Reply Last reply
    0
    • H Hulicat

      I have the following query that works, however; I need add another field "client_id" that I need to tie to client name in another table. I can't even add the client_id from the job_tickets table with this error: "select coMsg 8120, Level 16, State 1, Line 1 Column 'job_ticket.CLIENT_ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause." I need to display the "client_name" feild from "Clients" table that based off of dbo.job_tickets.client_id...I can do another inner join in the below starement? How do I achieve this? This works....I just to add the aforementioned select count(job_ticket_id) as 'Total', problem_type.problem_type_name 'Problem Type' from job_ticket inner join problem_type on dbo.problem_type.problem_type_id = job_ticket.problem_type_id where report_date between '1/01/2007' and '1/31/2007' group by problem_type.PROBLEM_TYPE_NAME any help is greatly appreciated.

      Regards, Hulicat

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Hulicat wrote:

      Column 'job_ticket.CLIENT_ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."

      Then add the column to the GROUP BY clause, just like the error message suggested you do.


      Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

      H 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Hulicat wrote:

        Column 'job_ticket.CLIENT_ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."

        Then add the column to the GROUP BY clause, just like the error message suggested you do.


        Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

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

        Right I know that would seem obvious, however; if I group by client_id. Then I get the same error for "problem_type.PROBLEM_TYPE_NAME" I did not know you could group by more than one column; I have not seen that I threw it in and it worked. ~Thanks~ -- modified at 20:14 Friday 11th May, 2007

        Regards, Hulicat

        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