Results 1 to 2 of 2

Thread: Cross tab problem

  1. #1
    Join Date
    Jan 2003
    Location
    UK
    Posts
    55

    Cross tab problem

    I'm trying to run the cross tab query so that it returns only one row. If there is data I want to dump in the field value (fText), otherwise I put in a dash. The problem I'm having is that it's returning multiple rows when I want a single one. I could create a # table and dump the data in, but it seems a bit long winded.

    Many thanks.


    SELECT distinct (CASE WHEN f.TypeID=1 THEN 1 ELSE 0 END) f1,
    (CASE WHEN f.TypeID=2 THEN f.fText else '-' END) f2,
    (CASE WHEN f.TypeID=3 THEN f.fText else '-' END) f3,
    (CASE WHEN f.TypeID=4 THEN f.fText else '-' END) f4,
    (CASE WHEN f.TypeID=5 THEN f.fText else '-' END) f5,
    (CASE WHEN f.TypeID=6 THEN f.fText else '-' END) f6,
    (CASE WHEN f.TypeID=7 THEN f.fText else '-' END) f7,
    (CASE WHEN f.TypeID=8 THEN f.fText else '-' END) f8,
    (CASE WHEN f.TypeID=9 THEN f.fText else '-' END) f9,
    (CASE WHEN f.TypeID=10 THEN f.fText else '-' END) f10
    FROM tblTest f WHERE (f.fID=219)

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Is fID unique field?

Posting Permissions

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