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
You need to use inline
CASEstatement for this,GROUP_CONCATand should be grouped byID. Give this a try.SQLFiddle Demo