Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8516489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:26:38+00:00 2026-06-11T05:26:38+00:00

I am new to SQL so please be kind. I am able to get

  • 0

I am new to SQL so please be kind. I am able to get all of the information by looking in the database and exporting it to excel. Once in excel I have to create forumlas to get it all the way I would like it. If at all possible I would like to just run a query to look at it all. I have Google’ed around but I can’t seem to find something that either makes sense to me or points me in the right direction.

I would think by my searches that there would be some kind of join but again being new to SQL I am grasping at straws.

Given the following sample tables:

Tickets Table:

ID    Queue  Owner  Subject            Status    TimeWorked    LastUpdated
001   1      22     need help          Open      20            2012-09-01
002   2      6      internet           Resolved  60            2012-09-03
003   1      24     email not working  Open      15            2012-09-04

Users Table:

ID    Name
6     Nobody
22    Josh
24    Jon

CustomFieldValue Table:

Id      ObjectId    CustomField    Content
01      001         1              Bob Inc
02      001         2              0
03      001         3              WaitingOnClient
04      001         4              Remote
05      002         1              ZYC Inc
06      002         2              15
07      002         3              WaitingOnClient
08      002         4              Remote
09      003         1              ACB Inc
10      003         2              0
11      003         3              TimeScheduled
12      003         4              OnSite

Queue Table:

ID    Name
1     Support
2     Tier2

What I would need to be able to do is query to get the results to look like the following

ID  Client  Subject   Queue    Owner  Status    Type   BTime CustomStat      LastUpdate NT
001 Bob Inc need help support  Josh   open      Remote 20    WaitingOnClient 2012-09-01 0
001 ZYC Inc internet  Tier2    Nobody Resolved  Remote 60    WaitingOnClient 2012-09-01 15
001 ACB Inc email     support  Jon    open      onsite 15    TimeScheduled   2012-09-01 0

Any help would be much appreciated.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:26:39+00:00Added an answer on June 11, 2026 at 5:26 am

    You need to use inline CASE statement for this, GROUP_CONCAT and should be grouped by ID. Give this a try.

    SELECT  a.ID,
            GROUP_CONCAT((CASE WHEN d.CustomeField = 1 THEN d.content ELSE NULL END)) `Client`,
            a.Subject,
            c.Name,
            b.Name Owner,
            a.`Status`,
            GROUP_CONCAT((CASE WHEN d.CustomeField = 4 THEN d.content ELSE NULL END)) `Type`,
            a.TimeWorked,
            GROUP_CONCAT((CASE WHEN d.CustomeField = 3 THEN d.content ELSE NULL END)) `CustomStat`,
            a.LastUpdated,
            GROUP_CONCAT((CASE WHEN d.CustomeField = 2 THEN d.content ELSE NULL END)) `NT`
    FROM    tickets a
            INNER JOIN users b
                ON a.owner = b.id
            INNER JOIN queue c
                ON a.queue = c.id
            INNER JOIN  CustomFieldValue d
                ON a.ID = d.ObjectID
     GROUP BY a.ID
    

    SQLFiddle Demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create an entirely new Sql Server 2008 database and want to
I'm kind of new to scripting in SQL and I have encountered an error
I am new to SQL.I have a database of mac-addresses which i created using
I am new to sql so please bear with me here. I have two
Please explain the SQL query given below. I m new with SQL and struggling
Question: The new SQL Server 2008 database returns me values formatted English (date/float). Is
I would like to be able to add a new SQL LOGIN and name
I`m new to sql and have been stuck on the following issue for almost
I'm new to SQL. I have a simple problem with getting the results from
I'm a little new to SQL and have come across the following problem. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.