SQL Question - Marking multiple columns for given data

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.

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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Multiple columns in a data file, but accounts not periods

    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 existing file, without changing it too much, but I think this might be beyond BPC!
    Thanks,
    Jason

    Hi there,
    The data I'm loading is actually Intercompany data for one unit, for one period.
    So I have my affiliate (or counterparty, whatever term you use) down the rows, and the designated intercompany accounts across the top.
    I don't need multiple columns for periods, as I'm only loading one period, but I would prefer to use multiple columns for Accounts dimension instead.
    I know I can nest affiliates and accounts in the rows, but as I mentioned I would rather avoid changing the data file as much as possible.
    Hope that make sense!
    Thanks,
    Jason

  • Get table partition name dynamically for given date range

    Dear All,
    Could you please tell me how to get the partition name dynamicaly for given date range ?
    Thank you.

    SQL> select table_name,
           partition_name,
           to_date (
              trim (
                 '''' from regexp_substr (
                              extractvalue (
                                 dbms_xmlgen.
                                 getxmltype (
                                    'select high_value from all_tab_partitions where table_name='''
                                    || table_name
                                    || ''' and table_owner = '''
                                    || table_owner
                                    || ''' and partition_name = '''
                                    || partition_name
                                    || ''''),
                                 '//text()'),
              'syyyy-mm-dd hh24:mi:ss')
              high_value_in_date_format
      from all_tab_partitions
    where table_name = 'SALES' and table_owner = 'SH'
    TABLE_NAME                     PARTITION_NAME                 HIGH_VALUE_IN_DATE_FORMAT
    SALES                          SALES_1995                     01-JAN-96               
    SALES                          SALES_1996                     01-JAN-97               
    SALES                          SALES_H1_1997                  01-JUL-97               
    SALES                          SALES_H2_1997                  01-JAN-98               
    SALES                          SALES_Q1_1998                  01-APR-98               
    SALES                          SALES_Q2_1998                  01-JUL-98               
    SALES                          SALES_Q3_1998                  01-OKT-98               
    SALES                          SALES_Q4_1998                  01-JAN-99               
    SALES                          SALES_Q1_1999                  01-APR-99               
    SALES                          SALES_Q2_1999                  01-JUL-99               
    SALES                          SALES_Q3_1999                  01-OKT-99               
    SALES                          SALES_Q4_1999                  01-JAN-00               
    SALES                          SALES_Q1_2000                  01-APR-00               
    SALES                          SALES_Q2_2000                  01-JUL-00               
    SALES                          SALES_Q3_2000                  01-OKT-00               
    SALES                          SALES_Q4_2000                  01-JAN-01               
    SALES                          SALES_Q1_2001                  01-APR-01               
    SALES                          SALES_Q2_2001                  01-JUL-01               
    SALES                          SALES_Q3_2001                  01-OKT-01               
    SALES                          SALES_Q4_2001                  01-JAN-02               
    SALES                          SALES_Q1_2002                  01-APR-02               
    SALES                          SALES_Q2_2002                  01-JUL-02               
    SALES                          SALES_Q3_2002                  01-OKT-02               
    SALES                          SALES_Q4_2002                  01-JAN-03               
    SALES                          SALES_Q1_2003                  01-APR-03               
    SALES                          SALES_Q2_2003                  01-JUL-03               
    SALES                          SALES_Q3_2003                  01-OKT-03               
    SALES                          SALES_Q4_2003                  01-JAN-04               
    28 rows selected.

  • Last Purchase price Warehouse wise for given date

    Hai all....
                      I Want query report for Last purchase price for all items, warehouse wise for given date, i tried following query
    SELECT
    T10.ItemCode,
    (Select i1.Itemname from  oitm i1 where i1.itemcode = T10.[ItemCode]) as 'ItemName',
    T10.[Whscode],
    (SELECT T1.[DocDate] FROM OPDN T1 where  T1.[DocEntry] = max(T10.[DocEntry])) as 'Doc_Date',
    (SELECT T1.[DocNum] FROM OPDN T1 where  T1.[DocEntry] = max(T10.[DocEntry])) as 'GRPO_NO',
    (SELECT case avg(T2.[Rate]) when 0 then avg(T2.[price]) else (avg(T2.[price]) * isnull(avg(T2.[Rate]),1)) end  FROM PDN1 T2 where  T2.[DocEntry] = max(T10.[DocEntry])
    and T2.Itemcode = T10.[ItemCode]) as 'Unit_Price',
    (SELECT isnull(avg(T3.[Rate]),0) FROM PDN1 T3 where  T3.[DocEntry] = max(T10.[DocEntry])
    and T3.Itemcode = T10.[ItemCode]) as 'CurrencyRate',
    (Select isnull(max(OP1.Docnum),0) from OPCH op1 where op1.Docentry in
    (SELECT T12.[trgetEntry] FROM PDN1 T12 where  T12.[DocEntry] = max(T10.[DocEntry]))) as 'Invoice_No'
    FROM PDN1 T10 
    INNER JOIN OPDN T11 ON T10.DocEntry = T11.DocEntry and T11.[DocType] = 'I'
    where T11.Docdate <= '[%0]' and t10.targettype <> 21
    GROUP BY
    T10.[ItemCode],T10.[Whscode]
    this query working good but problem in this query is ,when the user put back dated entry means this report will show wrong value,bcz i write this query based on MAX of docentry please help me to solve this issue
    Edited by: Prasanna s on Mar 27, 2009 5:49 AM
    Edited by: Prasanna s on Mar 27, 2009 8:00 AM

    Hai ...
    please help me in this query,my question is not clear or??

  • Stock report with value and qauntity for given date not month wise

    Hi gems,
    can any body give me the standard report for Stock value and qauntity for given date not month wise at storage location level

    Hi
    check the report S_P00_07000139 with the option inventory and raw material report- detail and selection date (from, to date same). List will give opening & closing balances with goods movment and their values.
    Thanks

  • Multiple columns for more than one record?

    Crystal Reports Xi
    I have a list of addresses, etc.  with attached route numbers.  If an address has 2 different route numbers, it will appear as two records.  Is there a way that I can list the address once, and have the route numbers just grow to more columns?
    Example - Change this...
    ADDRESS               ROUTE
    100 Main St.             1234
    100 Main St.             1235
    To This...
    100 Main St.            1234      1235
    Note:  An address may have one route number attached, or several route numbers attached.
    I tried playing around with the multiple columns, etc, but it kept on having everything in the section become multiple columns, etc.  Any help is appreciated.

    multiple columns only work in detail section.
    place your address without the route in the 1st details
    then insert a 2nd details and place the route in the details then select multiple columns for that details section.
    then underlay the first detail section and it should line up.

  • Storing multipl values for meta data in DOCUMENT_META_DATA

    Hi,
    We currently have 3 content types in our system: news, announcements, and events.
    They are currently stored in 3 different tables. We want to make this content
    available via the various CM (select) and PZ tags (contentquery, contentselector).
    I'd like to avoid writing my own doc provider (file:///D:/bea7/weblogic700/wlp/docs70/dev/conmgmt.htm#999019)
    and instead would like to begin to publish document data directly to the reference
    implementation tables (DOCUMENT and DOCUMENT_METADATA).
    It seems like I should be able to do that with one exception. It doesn't seem
    like we can store multiple values for meta data attributes. If you take the out
    of the box p13n example, a lot of the data is tagged with 'genre' = Something
    (i.e. Rock, Hip-hop, etc). Then content queries use this genre to personalize
    pages.
    What if I have a band that has multiple genres? What if I want to tag my band
    as Rock and Hip-hop? And then also want that band to appear on both a Rock lovers
    and a Hip hop groupies page? Is this possible with the default implementation?
    I know when I tried entering multiple 'genre' meta data values for a same document
    ID, it gave me a PK constraint violation. Any other trick around this?
    Thanks,
    Will Young
    ps. using weblogic 7...

    Yes Subler http://code.google.com/p/subler/ does support adding the HD tag.
    On the Mac I wouldn't use anything but Subler for tagging, best UI, best metadata lookup, best underlying libraries for mp4 files (I'm biased on the libraries part).
    Cheers Ed.

  • SD pricing extract for given date range

    Hi,
    Is any one knows any FM where you can able to extract pricing for given date range.
    FM Pricing works for one date. I don't want to loop at this
    FM for the given date rage. It takes very long time.
    Thanks for any suggestion.
    Kind Regards
    Nir

    Hi,
    Is any one knows any FM where you can able to extract pricing for given date range.
    FM Pricing works for one date. I don't want to loop at this
    FM for the given date rage. It takes very long time.
    Thanks for any suggestion.
    Kind Regards
    Nir

  • SQL Question Bank and Answers for Practise

    Dear Readers:
    Does any one have any recommendation on SQL question bank and answers where I could practice my SQL.
    I have developed some basic knowledge of SQL thanks to the MS community, but I am looking for some additional Questions or textbook  recommendations which has questions and answers to queries for practice.
    Best Wishes,
    SQL75

    Hi,
    Refer below post.
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/446b2247-5124-49c1-90c9-b7fea0aa4f83/sql-dba-books?forum=sqlgetstarted
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    Praveen Dsa | MCITP - Database Administrator 2008 |
    My Blog | My Page

  • Call Multiple RTF for same data model

    How call two templates for the same data model.
    what is the logic i have to use in the rtf template.
    Thanks in Advance

    Your RTF template will use the data model you defined.
    So no logic than just inserting the xml elements your data model provides.
    You can associate multiple templates to one data model. At runtime you will have the opportunity to select
    the template of your desire to run the data against.
    If you want this process to be automated then you will have to user bursting and for that you need to read this:
    http://download.oracle.com/docs/cd/E14571_01/bi.1111/e13881/T527073T555155.htm#T555156
    Cheers
    Jorge
    p.s If this answers your question then please grant the points and close the thread

  • Simple Question: How to search for a date value in SELECT

    Probabily a simple question, but in a SELECT statement, how do you do a search for a date value in the WHERE clause?
    example:
    Select * From Example
    Where date = 01/01/2001
    I know its not as simple as that, but what change has to occur to make it do what that example implies?
    Thanks In Advance.

    If you want to avoid the conversion part(to_date) you will need to specify the date in the format as ur nls date format.so the same query might not work if you change ur nls date format.
    so it is advisable to give it in general format.
    ie where date_col=to_date(01-01-2000,'dd-mm-yyyy')

  • What type of questions can i expect for master data?

    hi,
    am preparing for the interview. pls... let me know those questions for master data.
    thanks to all

    HI arun,
    Pl. be clear on
    what is master data, purpose, customer master data fields and material master data imp fields.
    common distribution channels and divisions.
    Org. master data. ( interms of one to many , many to many relations of org elements ).
    condition master data
    How master data is uploaded and maintained.
    Hope it helps. Pl. reward if useful.
    Thanks
    Sadhu Kishore

  • How to get organisation unit for given date.

    Hi Everyone,
    I have created a report to display all the hired and left employees
    for the given date. I have to display department wise.
          CALL FUNCTION 'RH_DIR_ORG_STRUC_GET'
            EXPORTING
             ACT_ORGUNIT           = S1_ORGEH-LOW
             ACT_PLVAR             = '01'
             ACT_DATE              = SO_DATE-HIGH
             SORT_FLAG             = 'X'
             ADD_FLAG_PDATA        = 'X'
           TABLES
             ORG_UNITS             = IT_ORG_UNITS.
    This function module will bring all the active org unit existing
    in our system. If an organisation unit is delimited.
    This function module is not getting the delimited org unit.
    How to get that org unit.
    Plz its vry urgent,
    thanks in advance,
    regards,
    stanley

    did you try RH_STRUC_GET?
    Regards
    Raja
    close your previous threads
    Re: ALV in browser

  • Discovering the day of the week for given date

    hi guys, im trying to discover the day of the week for a given date when i do this it works fine:
    select to_char(sysdate,'FMDAY') from dual
    however, when i try to pass in my own value as a parameter i get the error: invalid number
    select to_char(:mydate,'FMDAY') from dual .
    the value im passing through to mydate is 21/02/2011 so i have no idea why it is not working. Any help would be greatly appreciated. thanks
    Edited by: 786733 on 21-Feb-2011 03:41

    786733 wrote:
    hi guys, im trying to discover the day of the week for a given date when i do this it works fine:
    select to_char(sysdate,'FMDAY') from dual
    however, when i try to pass in my own value as a parameter i get the error: invalid number
    select to_char(:mydate,'FMDAY') from dual .
    the value im passing through to mydate is 21/02/2011 so i have no idea why it is not working. Any help would be greatly appreciated. thanksyou're probably passing in a string instead of a date, so you need to convert it to a date with the appropriate format.
    select to_char(to_date(:mydate,'DD/MM/YYYY'),'FMDAY') from dual

  • Question marks in PDF for non-english characters.

    I'm get report from APEX 3.0.1 (Default Report Layout) with BI Publisher 10.1.3.3.1 Base.
    In Adobe Reader 7.0.8 instead of non-english(cyrillic) characters see question marks.
    How to tune BI Publisher?

    After installation BI Publisher 10.1.3.3.1 Base (standalone, OC4J) :
    Directory of F:\bip\jdk\lib\fonts
    13/10/2007 21:16 15 196 128R00.TTF
    13/10/2007 21:16 18 473 348 ALBANWTJ.ttf
    13/10/2007 21:16 18 777 132 ALBANWTK.ttf
    13/10/2007 21:16 18 676 084 ALBANWTS.ttf
    13/10/2007 21:16 18 788 600 ALBANWTT.ttf
    13/10/2007 21:16 276 384 ALBANYWT.ttf
    13/10/2007 21:16 12 860 B39R00.TTF
    13/10/2007 21:16 18 800 MICR____.TTF
    13/10/2007 21:16 6 580 UPCR00.TTF
    Directory of F:\bip\jdk\jre\lib\fonts
    01/08/2006 19:25 75 144 LucidaBrightDemiBold.ttf
    01/08/2006 19:25 75 124 LucidaBrightDemiItalic.ttf
    01/08/2006 19:25 80 856 LucidaBrightItalic.ttf
    01/08/2006 19:25 344 908 LucidaBrightRegular.ttf
    01/08/2006 19:25 317 896 LucidaSansDemiBold.ttf
    01/08/2006 19:25 698 236 LucidaSansRegular.ttf
    01/08/2006 19:25 234 068 LucidaTypewriterBold.ttf
    01/08/2006 19:25 242 700 LucidaTypewriterRegular.ttf
    Directory of F:\bip\jre\1.4.2\lib\fonts
    24/03/2004 19:12 75 144 LucidaBrightDemiBold.ttf
    24/03/2004 19:12 75 124 LucidaBrightDemiItalic.ttf
    24/03/2004 19:12 80 856 LucidaBrightItalic.ttf
    24/03/2004 19:12 344 908 LucidaBrightRegular.ttf
    24/03/2004 19:12 317 896 LucidaSansDemiBold.ttf
    24/03/2004 19:12 698 236 LucidaSansRegular.ttf
    24/03/2004 19:12 234 068 LucidaTypewriterBold.ttf
    24/03/2004 19:12 242 700 LucidaTypewriterRegular.ttf
    What is wrong?
    In Adobe Reader's Document Properties -> Fonts
    +Helvetica:
    Type: Type1
    Encoding: Ansi
    Actual Font: ArialMT
    Actual Font Type: TrueType
    I feel BIP use wrong encoding . . .

Maybe you are looking for

  • Reporting Services connecting to a PowerPivot Workbook hosted on Sharepoint Online

    Hi, we developed a PowerPivot Workbook and published on our PowerBI site based on a Sharepoint Online E3 subscription. We use it to display PowerView Dashboard and analyse sales results. On-prem we also have a Reporting Services (stand alone installa

  • Using functions in plsql

    Hello All: My question is, Which is more efficient to use in Plsql: IF v_DestFile IS NULL THEN v_DestFile := in_DestFile ; END IF; OR v_DestFile := NVL(v_DestFile , in_DestFile); Using the second one requires a call to a function.. What are your thou

  • 10.1.0.3 install on mac laptop

    Has anyone able to install the 10g database on PowerBook G4? I get TNS: Lost contact error at the end and unable to create Oracle database.

  • Grand Total function on a report

    The Grand Total function is working for only one of the two columns I need it to work in for my report. The data in the column in question is text data that has been CASTed to Integer with no issues but still won't display a grand total. Exporting to

  • Data import for CAF generated tables

    Hello, I developed a CAF application with custom Web Dynpro UI. As the persistency up to now just consists of "Local persistency", all the data is stored in CAF tables on my NW2004s system. I know that I can create records "by hand" in the Service Br