Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506

    Unanswered: Cross-Tab vs SQL query

    Hi,
    I have a report like this....
    Code:
    Date           Sam  Tom  Harry  2006  2005
    02/01/2006       4      1     1      6      2
    02/02/2006       3      1     1      4      5
    02/03/2006       2      2     0      4      4
    -------
    -------
    
    
    02/12/2006       1      1      1     3       1 
    ------------------------------------
    Total               --     --     --    --      --
    Now I have all the data required for that in one table.
    Code:
    CREATE TABLE t1(
                             indate DATETIME
                            ,agname VARCHAR(60)
                            ,Polnumber VARCHAR(20)
                           )
    So I have 2 options :
    I have to do in in Cross tab or I have to create a query for this.
    Is it possible to built a query like this,I mean assigning data as column?

    Any help will be greatly appreciated.
    Thanks!!
    Last edited by rudra; 09-15-06 at 03:36.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by rudra
    Is it possible to built a query like this,I mean assigning data as column?
    Yep. If there are a fixed number of possible column values you can use CASE. If not then you need to use dynamic SQL (e.g. http://www.experts-exchange.com/Data....html#16500817,
    http://www.sqlmag.com/Articles/Index...rticleID=15608,
    http://www.sqlteam.com/item.asp?ItemID=2955). I've not used any of the above - I just have them bookmarked in case I need them.

    BTW - your better option might be the front end doing this if at all possible

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Thanks a lot pottie for those links.I will give it a try tonight...Thanks once again..
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

Posting Permissions

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