• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "SQL query and reports"

Collapse

  • Drkarnivore
    replied
    Late to the party.

    If you are sans reporting tool, many databases have a PIVOT / UNPIVOT function for dealing with such problems in SQL.

    Leave a comment:


  • Fandango
    replied
    You can use a matrix and put the AuditTypeID in the column group field, this would in give you a dynamic number of columns based on the distinct number of AuditTypeIDs you have across the rows. Effectively a Pivot table.

    This vid demonstrates it in SSRS so should be applicable in RB3 although he parameterises which columns he wants to use but should give you the idea

    The only caveat though is I'm pretty sure you would get a column for every AuditTypeID that appears in your dataset, and that would be applied across all your rows(invoices) regardless of whether each row has a values for each audittypeid

    https://youtu.be/vgtVJf21EXU


    the other option is to flatten the rows in the SQL statement and concatenate the AuditTypeID into a single string

    http://www.sqlmatters.com/Articles/C...%20string.aspx

    Leave a comment:


  • MarillionFan
    replied
    Originally posted by LondonManc View Post
    Can you be more specific on how you want your output to look?

    The solution may vary - i.e. you could cobble together a little function to concatenate date and details or something similar.
    It doesn't matter now, the budget has caused him to go permie.

    Leave a comment:


  • LondonManc
    replied
    Originally posted by original PM View Post
    Hi Clever People,

    can anyone help

    We have an audit table within one of our systems which looks like

    InvoiceNumber Date EmployeeID AuditTypeID Details
    M12345 07/05/2010 0 4 Invoice Printed
    M12345 09/03/2010 0 5 Payment Received £116.00
    M12345 24/06/2010 0 5 Payment Received £462.00
    M12345 10/06/2010 0 11 Letter 1 sent

    However I want to write a report which then makes the items appear in a row such as that each invoice number has only 1 row with the various audit items going horizontally

    Using report builder 3 to generate the reports

    Anyone any ideas?

    TIA
    Can you be more specific on how you want your output to look?

    The solution may vary - i.e. you could cobble together a little function to concatenate date and details or something similar.

    Leave a comment:


  • DanielSQL
    replied
    Not sure I've used report builder before. But a simple group by query should give you the result you desire.

    Grouping by the invoice number, date and then audit item should give you the result you require. Straight forward group by query then throw that into your report

    Might be worth putting an example of how you want the result set to look. Into a spreadsheet and posting a screenshot on here. Should be able to give you some more advice - should you still require it of course.
    Last edited by DanielSQL; 22 June 2015, 07:08.

    Leave a comment:


  • darrylmg
    replied
    Originally posted by eek View Post
    So basically a Step Report....
    I don't know what the Microsoft gui tools like to call it, but it sounds like they are one and the same.
    Didn't MS Access have something similar for reporting with a "Group By"?

    Leave a comment:


  • eek
    replied
    Originally posted by darrylmg View Post
    That sounds like a transposition.
    You can do it in a stored procedure if you can program, or dump a basic report to Excel and transpose there.
    Either way, I wouldn't recommend that format, because you don't know how many columns or length of data you're going to need to join together. You might run out of space to properly view it (if you know what I mean).
    You might be beter off using a basic grouping function, which would group by invoice id, then have a date sorted sub-row for each of the audit details against that invoice.
    This would probably be better because you could then quickly duplicate that report, changing it to group instead by date or account, or employee. Providing you with the differing views you might want to see if you were investigating fraud.
    So basically a Step Report....

    Leave a comment:


  • darrylmg
    replied
    That sounds like a transposition.
    You can do it in a stored procedure if you can program, or dump a basic report to Excel and transpose there.
    Either way, I wouldn't recommend that format, because you don't know how many columns or length of data you're going to need to join together. You might run out of space to properly view it (if you know what I mean).
    You might be beter off using a basic grouping function, which would group by invoice id, then have a date sorted sub-row for each of the audit details against that invoice.
    This would probably be better because you could then quickly duplicate that report, changing it to group instead by date or account, or employee. Providing you with the differing views you might want to see if you were investigating fraud.

    Leave a comment:


  • eek
    replied
    Originally posted by stek View Post
    Could you sed it in Unix to remove the CR's?
    you could just send it to another windows program. I just don't know enough about SSRS to say how to do it within Report Builder itself....

    Leave a comment:


  • stek
    replied
    Originally posted by eek View Post
    https://msdn.microsoft.com/en-us/library/dd220467.aspx shows you how to create a stepped report which would give you something like

    M12345
    07/05/2010 0 4 Invoice Printed
    09/03/2010 0 5 Payment Received £116.00
    24/06/2010 0 5 Payment Received £462.00
    10/06/2010 0 11 Letter 1 sent

    I'm not sure how you merge detail rows to appear on a single row though...
    Try this if you can do some Unix to the output in a file...

    tr '\r\n' ' ' < origfile > newfile
    Last edited by stek; 17 June 2015, 19:22.

    Leave a comment:


  • eek
    replied
    Originally posted by original PM View Post
    Hi Clever People,

    can anyone help

    We have an audit table within one of our systems which looks like

    InvoiceNumber Date EmployeeID AuditTypeID Details
    M12345 07/05/2010 0 4 Invoice Printed
    M12345 09/03/2010 0 5 Payment Received £116.00
    M12345 24/06/2010 0 5 Payment Received £462.00
    M12345 10/06/2010 0 11 Letter 1 sent

    However I want to write a report which then makes the items appear in a row such as that each invoice number has only 1 row with the various audit items going horizontally

    Using report builder 3 to generate the reports

    Anyone any ideas?

    TIA
    https://msdn.microsoft.com/en-us/library/dd220467.aspx shows you how to create a stepped report which would give you something like

    M12345
    07/05/2010 0 4 Invoice Printed
    09/03/2010 0 5 Payment Received £116.00
    24/06/2010 0 5 Payment Received £462.00
    10/06/2010 0 11 Letter 1 sent

    I'm not sure how you merge detail rows to appear on a single row though...

    Leave a comment:


  • original PM
    started a topic SQL query and reports

    SQL query and reports

    Hi Clever People,

    can anyone help

    We have an audit table within one of our systems which looks like

    InvoiceNumber Date EmployeeID AuditTypeID Details
    M12345 07/05/2010 0 4 Invoice Printed
    M12345 09/03/2010 0 5 Payment Received £116.00
    M12345 24/06/2010 0 5 Payment Received £462.00
    M12345 10/06/2010 0 11 Letter 1 sent

    However I want to write a report which then makes the items appear in a row such as that each invoice number has only 1 row with the various audit items going horizontally

    Using report builder 3 to generate the reports

    Anyone any ideas?

    TIA

Working...
X