Results 1 to 11 of 11
  1. #1
    Join Date
    Jan 2004
    Posts
    164

    Unanswered: Headers on a report

    I wanted to show header titles for each group of accounts. Ho would I be able to do that. The query that I have right now is:

    select * from apcopah
    where substring(ap_control_acct, 1, 4) = '1624'
    and date_vendor_inv >= '2001-08-01'
    or substring(ap_control_acct, 1, 4) = '1631'
    and date_vendor_inv >= '2001-08-01'
    or substring(ap_control_acct, 1, 4) = '1632'
    and date_vendor_inv >= '2001-08-01'

    I would like it to look like this:

    Utilities

    Ap_control_acct date_vendor_inv
    1624 2001-10-01
    1624 2001-12-01

    Audit Fees

    Ap_control_acct date_vendor_inv
    1631 2002-09-01
    1631 2002-10-01


    Is this possible?
    Last edited by estefex; 11-23-04 at 13:11.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Nearly every reporting tool I've ever used can do that. They all have different mechanics for how they do it, but they've all been able to do it somehow.

    -PatP

  3. #3
    Join Date
    Jan 2004
    Posts
    164
    Is there a way to do it with t-sql code?

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
       SELECT 'UTILITIES'+CHAR(13)+CHAR(10)
    UNION ALL
       SELECT Ap_control_acct date_vendor_inv
         FROM apcopah
        WHERE SUBSTRING(ap_control_acct, 1, 4) = '1624' 
          AND date_vendor_inv >= '2001-08-01'
    UNION ALL
       SELECT 'AUDIT FEES'+CHAR(13)+CHAR(10)
    UNION ALL
       SELECT Ap_control_acct date_vendor_inv
         FROM apcopah
        WHERE SUBSTRING(ap_control_acct, 1, 4) = '1631' 
          AND date_vendor_inv >= '2001-08-01'
    UNION ALL
       SELECT '1632'+CHAR(13)+CHAR(10)
    UNION ALL
       SELECT Ap_control_acct date_vendor_inv
         FROM apcopah
        WHERE SUBSTRING(ap_control_acct, 1, 4) = '1632' 
          AND date_vendor_inv >= '2001-08-01'
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Actually, it's more like

    Code:
       SELECT 'UTILITIES'+CHAR(13)+CHAR(10)+ 'Ap_control_acct date_vendor_inv'
    UNION ALL
       SELECT CONVERT(char(5),Ap_control_acct) + SPACE(11) + CONVERT(char(10),date_vendor_inv)
         FROM apcopah
        WHERE SUBSTRING(ap_control_acct, 1, 4) = '1624' 
          AND date_vendor_inv >= '2001-08-01'
    UNION ALL
       SELECT 'AUDIT FEES'+CHAR(13)+CHAR(10)+ 'Ap_control_acct date_vendor_inv'
    UNION ALL
       SELECT CONVERT(char(5),Ap_control_acct) + SPACE(11) + CONVERT(char(10),date_vendor_inv)
         FROM apcopah
        WHERE SUBSTRING(ap_control_acct, 1, 4) = '1631' 
          AND date_vendor_inv >= '2001-08-01'
    UNION ALL
       SELECT '1632'+CHAR(13)+CHAR(10)+ 'Ap_control_acct date_vendor_inv'
    UNION ALL
       SELECT CONVERT(char(5),Ap_control_acct) + SPACE(11) + CONVERT(char(10),date_vendor_inv)
         FROM apcopah
        WHERE SUBSTRING(ap_control_acct, 1, 4) = '1632' 
          AND date_vendor_inv >= '2001-08-01'
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    The above SQL, innovative and resourceful as it is, is a perfect example of why presentation formatting such as you are describing is best left to the presentation layer of your application.

    SQL Server is not a report server, and Query Analyzer is not a user interface!
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I'm just gushing.....

    But I do tend to agree...unless it's not in my best interest, then I don't.

    Have you had a look at reporting services yet?

    I haven't but I'm dying to check it out.

    Oh, and my mainframe DB2 Roots...getting data out in a format that looks like EXCEL with headers and all is a daily occurance....I just use an Unload utility...sort of like bcp with query out...

    No need for an "application"


    Oh, and btw...QA IS a user interface...
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  8. #8
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by estefex
    Is there a way to do it with t-sql code?
    Yes, but you still shouldn't do that. It can be done, just like you can use a socket wrench to drive nails or a hammer to remove bolts... In my opinion, it is a clear case of the wrong tool for the job.

    -PatP

  9. #9
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    QA a user interface?

    Terminology, I suppose.

    I consider QA to be a developer and administrator interface. I use QA, but I wouldn't put it in front of a secretary, data-entry clerk, or any other application "user"! I'd be spending half my hours answering help-desk calls!
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  10. #10
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Sure enough....

    DROP DATABASE
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  11. #11
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    ...or my favortite, the deceptively named

    "DBCC DBREPAIR"

    Huh? Where'd it go? Well I guess it ain't broke no more...
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •