--SELECT * FROM	dbo.custport_klaim WHERE no_klaim IN ('C1609000021','C1610000021')
--SELECT * FROM	dbo.custport_klaim_aai WHERE id_klaim IN (480,509)
--SELECT * FROM	dbo.custport_from_aai_header WHERE claim_register IN ('C1609000021','C1610000021')
--SELECT * FROM	dbo.custport_from_aai_header_history WHERE claim_register IN ('C1609000021','C1610000021')

SELECT
  received_date,
  received_rawdata,
  ip_address,
  response,
  response_date,
  CAST((response_date-received_date) as time(3)) '[hh:mm:ss]'
FROM
  dbo.custport_from_aai
WHERE
  received_date > '2016-09-01'

SELECT
  xml_content,
  sent_date,
  response,
  response_date,
  status_code,
  status_text,
  status_description,
  CAST((response_date-sent_date) as time(3)) '[hh:mm:ss]'
FROM
	dbo.custport_klaim_aai
WHERE
  sent_date > '2016-09-01'