0

I have this syntax for MySql database and it outputs the right data. If you can spare some time helping me with this, I can really use it on a LOT of my MySql queries.

SELECT eh.contract_reference as 'Reference', eh.ClientCode as 'Client Code', cm.name as 'Name', eh.ChassisNo as 'Chassis No.', eh.ChassisType as 'Chassis Type', con.effective_date as 'Effectivity', con.expiry_date as 'Valid Until', con.Status as 'Status'
FROM delwater_rockyonline.eirheader as eh
JOIN delwater_MasterDB.client_mstr as cm
ON eh.ClientCode = cm.code
JOIN delwater_masterdb.contract_mstr as con
ON eh.contract_reference = con.reference
WHERE con.Status= 'DRAFT'

it gives me a result like so: enter image description here

what I need is something like this: enter image description here

All help is very much appreciated.

Ibanez1408
  • 4,550
  • 10
  • 59
  • 110
  • you do not put repeating data in a column – e4c5 Oct 26 '16 at 05:32
  • 2
    I can't think of an easy way to do this, not without giving you an ugly query. Typically, you would handle this in the presentation layer. Have you looked into handling this in Excel (?), where it might be easier? – Tim Biegeleisen Oct 26 '16 at 05:33
  • I think it would be really hard to achieve (even if possible) in SQL. Not to mention it would degrade performance of whatever query you come up with. As Tim suggested, presentation layer is the best place to do this. BUT if you really want to give it a go, here is a hint http://stackoverflow.com/questions/13742572/how-to-show-blank-record-in-sql-if-duplicate-rows-exists – Hassan Oct 26 '16 at 05:44
  • Yes Tim, I think we can manipulate it in Excel. I am just thinking if I can do it in the query result immediately. – Ibanez1408 Oct 26 '16 at 05:45

0 Answers0