Current Position:Home > SQL Question - Marking multiple columns for given data

SQL Question - Marking multiple columns for given data

Update:11-30Source: network consolidation
Advertisement
Hello everybody,
I have an sql problem that I can't solve.
Any comments, examples or resources will be welcomed about situation. I believe 'net is full of examples like this but I really can't realize how to search this.
My data is something like this:
        ID      CTYPE
         1          1
         1          1
         1          2
         2          4
         3          3
         3          1
         4          5
         5          8
         6          9And desired output is:
ID TYPE1 TYPE2 TYPE3 TYPE4
  1     X     X           
  2                       X
  3     X           X      You may reproduce the case with:
drop table bilal_deneme purge;
create table bilal_deneme(id number, ctype number);
insert into bilal_deneme values(1,1);
insert into bilal_deneme values(1,1);
insert into bilal_deneme values(1,2);
insert into bilal_deneme values(2,4);
insert into bilal_deneme values(3,3);
insert into bilal_deneme values(3,1);
insert into bilal_deneme values(4,5);
insert into bilal_deneme values(5,8);
insert into bilal_deneme values(6,9);
select * from bilal_deneme;Thanks in advance.

The Best Answer

Advertisement
This may give you a start
SQL> select id,max(decode(ctype,1,'X')) "1",
  2            max(decode(ctype,2,'X')) "2",
  3            max(decode(ctype,3,'X')) "3"
  4  from bilal_deneme purge
  5  group by id;
        ID 1 2 3
         1 X X
         6
         2
         4
         5
         3 X   X
6 rows selected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  • SQL Question - Marking multiple columns for given data Update:11-30

    Hello everybody, I have an sql problem that I can't solve. Any comments, examples or resources will be welcomed about situation. I believe 'net is full of examples like this but I really can't realize how to search this. My data is something like thi

  • Multiple columns in a data file, but accounts not periods Update:10-11

    Hi there, A very quick question. If I have a data file with, for example AcctDetail down the side and accounts across the top, am I right in thinking I can't load like this? Is it only periods that can be in multiple columns? I'm trying to adapt an e

  • Use of PL/SQL to populate table columns from XML data file Update:10-11

    I'm trying to find the easiest way to transfer data from a flat file that is in XML format into a traditional Oracle table. Not retaining the XML but actually map an XML element to a column so standard SQL, Forms, Reports, etc can access like it was

  • SQL*Loader . A column value in data file contains comma(,) Update:11-30

    Hi Friends, I am getting an issue while loading a csv file to database. A column in datafile contains a comma .. how to load such data? For ex, a record in data file is : 453,1,452,N,5/18/2006,1,"FOREIGN, NON US$ CORPORATE",,,310 Here "FORE

  • Multiple Columns in Measurement files .tdm Update:11-30

    I'm using a 'write to measurement file vi' to write to .tdm files, and I need multiple columns worth of data. How do I use a combo box  to toggle between different data sets? We've already used combo boxes to differentiate between different file name

  • Multiple Column with no information Update:11-30

    I have a Crystal Report 10 report made that uses multiple columns for the data in each group. The printing direction is set to be "Across then Down". Suppose a group has 10 rows. When I preview and export from Crystal Developer 10, the two colum

  • To display comma separted value into multiple column Update:11-30

    Hi, I want to display value into multiple column like below data is like this col1 res_menaHome:MenaHome res_menaHomeEmp:MenaHome Employee res_MDSpecialSer:MD Special Services res_Smart:Smart now i want to display like col1 col2 res_menaHome MenaHome

  • Using sql load insert multiple fields data into a single column in database Update:10-11

    Hi , I have my log file in sun OS box something like this ======= (07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011 (07/29/2009 00:02:26.236) 3675 (07/29/2009 00:02:28.207) 949395117 (07/29/2009 00:02:28.240) 337710 (07/29/2009 00:

  • Question on Multiple Date columns Update:11-30

    Hello all, I have like 7 to 10 fact tables . In each fact table I have one date column..Some facts have 2 or 3 date columns for example , I have Activations Fact table in which I have Disconnect_Date and Activation_Date...both should be joined to Dat

  • SQL Query returns question marks Update:11-30

    I am seeing a SQL Query, executed via ADODB in VB, from a 10G client (don't know exact version) to a Sun Solaris based 9.2.0.5.0 Server return all question marks...Table queried consists of 3 columns, 2 varchar2, one long: Here query: SELECT SETTINGV