Hi Team,
I am pulling a report by querying the SQL box. One of my friends helped me and gave the below query and it works fine. I just need your help to add two more columns in the report ('Customer User' & 'CustomerID') . Could you please assist me in completing the query?
SELECT CONCAT_WS ('', u1.first_name, u1.last_name) AS CREATED_BY_AGENT,
t.tn AS TicketNumber,
t.title AS TITLE,
CONCAT_WS ('', u2.first_name, u2.last_name) AS OWNER,
q.name AS QUEUE ,
ts.name AS STATE,
dfv2.value_text AS CITY,
dfv3.value_text OFFICE AS
FROM Ticket t
LEFT JOIN Users U1 ON (t.create_by = u1.id)
LEFT JOIN Users U2 ON (t.user_id = u2.id)
LEFT JOIN Queue q ON (t.queue_id = q.id)
LEFT JOIN ticket_state TS ON (t.ticket_state_id = ts.id)
LEFT JOIN dynamic_field_value dfv2 ON (t.id = dfv2.object_id AND dfv2.field_id IN ('74') )
LEFT JOIN dynamic_field_value dfv3 ON (t.id = dfv3.object_id AND dfv3.field_id IN ('37'))
WHERE t.create_time LIKE '2015-09 - %%'
ORDER BY u1.id
Note: I have nil knowledge in SQL and my DBA could not assist me, hence this request.
Cheers
Deepak
OTRS - 4.0.7
Ubuntu - 14.04
Apache - 2.4.7
MySQL - 5.5.41
SOLVED : Need Assistance in a SQL Query
Moderator: crythias
SOLVED : Need Assistance in a SQL Query
Last edited by hkshetty on 15 Sep 2015, 04:04, edited 1 time in total.
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Need Assistance in a SQL Query
This isn't something that needs to be answered directly from this site.
If you don't know what the ticket table schema is, you should know how to DESCRIBE ticket to determine the columns.
t.customer_id AS CustomerID,
t.customer_user_id AS "Customer User",
If you don't know what the ticket table schema is, you should know how to DESCRIBE ticket to determine the columns.
t.customer_id AS CustomerID,
t.customer_user_id AS "Customer User",
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
SOLVED : Need Assistance in a SQL Query
Thank you so much Crythias for your time & advice! 
