Uri Dimant
3/26/2007 1:33:00 PM
Again, since you have not posted DDL+sample data+ an expected result I guess
you need to use a CASE expression
"Per Henrik Oja" <per@oja.no> wrote in message
news:4607cb32$1@news.broadpark.no...
>I guess I wasn't clear enough. I want a view from a table I already have
>imported. (A rather flat and silly 100 field long thingy.) From this I want
>a view where one of the fields contains "Gates, iRack" etc based on the
>silly 1's and 0's in the table. So I need help with the SQL-syntax to
>generate this.
>
> perh
>
> Uri Dimant skrev:
>> Hi
>> As I understood from you narrative your problem is how you desined the
>> table
>>
>> Why don't you have somethimg like that
>>
>> create table test
>> (
>> row_id int not null primary key,
>> companyname varchar(100) not null,
>> contactperson varchar(100) not null,
>> project_involved_in varchar(200) not null default 'not involved in'
>> )
>>
>> insert into test values (1,'Microsoft Inc','Bill "Humor me"
>> Gates','iRack')
>> insert into test values (1,'Microsoft Inc','Bill "Humor me"
>> Gates','watergate')
>> ..................................
>>
>>
>>
>>
>> "Per Henrik Oja" <per@oja.no> wrote in message
>> news:4607c568$1@news.broadpark.no...
>>> Hi.
>>> I'm trying to build a field from the values in 4 other fields. The four
>>> fields contain 0's and a 1's to mark involvement in a project. So the
>>> table looks about like this:
>>>
>>> CompanyName: Microsoft Inc.
>>> ContactPerson: Bill "Humor me" Gates
>>> Is_involved_in_watergate: 1
>>> Is_involved_in_iRack: 1
>>> Is_involved_in_peace: 0
>>> Is_involved_in_any_innovation:0
>>>
>>> Then I want to build a field where it lists all the projects he's
>>> involved in. So the output looks like this:
>>>
>>> CompanyName: Microsoft Inc.
>>> ContactPerson: Bill "Humor me" Gates
>>> new_field_INVOLVED_IN: watergate, iRack
>>>
>>> The values watergate and iRack is not directly linked to the field-name
>>> in the first table.
>>>
>>> I have made this in Access with elaborate if-nesting, but i cant seem to
>>> get the if-syntax right for MS-server. And I'm sure there is a better
>>> way to do this. Oh, just to have mentioned this: The first table is not
>>> possible to alter, so replays addressing the poor db-design is really
>>> not wanted :)
>>>
>>> Regards
>>> Per Oja
>>