How to create a Matrix table using this data in SQL Query Analyzer

Hello all,
I have a problem while I am trying to represent my Sql Table namely table1 in Matrix form
my table Format is
city1 city2 Distance--------------------------------------------------------
Mumbai Delhi 100
Delhi Banaras 50
Mumbai Rajasthan 70
Banaras haryana 40
Mumbai Mumbai 0
784 entries
there are 784 cities each having link to other
Now i want my output as
Mumbai Delhi Banaras haryana
Mumbai 0 100 -- --
Delhi 100 0 50 --
Banaras
haryana
respective distance from one city to other should be shown
final Matrix would be 784*784
I am using SQL Query Analyser for this
Please help me in this regard

I'm pretty much certain that you don't want to do this in pure SQL. So that means that you want to do it with a reporting tool. I'm not familiar with SQL Query Analyzer, but if it is in fact a reporting tool you'll want to consult its documentation looking for the terms "pivot" or perhaps "cross tab."

Similar Messages

  • Need help on how to create the simple mapping using ORACLE DATA INTEGRATOR

    Hi guys,
    am new to learn odi.. please share me or steps how to develop the simple mapping using ODI...

    Hi,
    I am a newbie to Oracle Data Integrator as well. You should have a look here first; http://www.business-intelligence-quotient.com/?p=379
    Try to play around with ODI and then come back if you have specific questions. You should better move to this ODI-forum; Data Integrator
    Good Luck,
    Daan Bakboord
    http://obibb.wordpress.com

  • Lookup creation and using this lookup in SQL query

    I Have two tables one table called T_KEY_VALUES (KEY_ID , VALUE) and other is my transition table T_TRANSACTIONS (VERSION_ID , COL_VENDOR , COL_PREFIX, COL_RECIPTID , COL_STATE , COL_COUNTRY ..)
    The data looks like below:
    T_KEY_VALUES:
    KEY_ID , VALUE,
    10, CA
    11, NY
    13, NJ
    20, USA
    21, CANADA
    101 , AMC
    102, REGAL
    1001, MOVIES
    1002, MALLS
    T_TRANSACTIONS:
    VERSION_ID , COL_VENDOR , COL_PREFIX , COL_RECIPTID , COL_SATE , COL_COUNTRY
    1, 101 , 1001 , 100001 , 10 , 20
    2, 102 , 1002  , 100002 , 11 ,20
    Generally, COL_VENDOR, COL_PREFIX , COL_STATE , COL_COUTRY field values exist in the T_KEY_VALUES table.
    So How can I use T_KEY_VALUES as Lookup and write the one SQL query to get the data like below:
    1, AMC , MOVIES , 100001 , CA ,USA
    2, REGAL , MALLS , 100002 , NY , USA

    Hi,
    One way is to join t_transactions to 4 copies of t_key_values:
    SELECT  t.version_id
    ,       v.value           AS vendor
    ,       p.value           AS prefix
    ,       t.col_reciptid
    ,       s.value           AS state
    ,       c.value           AS country
    FROM    t_transactions  t
    JOIN    t_key_values    v  ON  v.key_id  = t.col_vendor
    JOIN    t_key_values    p  ON  p.key_id  = t.col_prefix
    JOIN    t_key_values    s  ON  s.key_id  = t.col_state     -- or col_sate
    JOIN    t_key_values    c  ON  c.key_id  = t.col_country
    If you'd care to post CREATE TABLE and INSERT statements for the sample data, then I could test this.
    The query above assumes all 4 coded columns in t_transactions have matching values in t_key_values, as they do in the sample data.  If that assumption is wrong, then use outer joins in some (or all) of the places where I used inner joins above.
    Another approach is to UNPIVOT t_transactions into 4 times as many rows, do a single join to t_key_values, and then PIVOT those results back to the original number of rows.

  • How to create the Hierarchial table using ALV.in WD4A

    Hi All,
    I am struggling hard to make the hierarchial ALV,  But could not do it.
    Could you help me.
    Actually I want the column to be hierarchial. For this i am using
    if_salv_wd_column_hierarchy~set_hierarchy_column.
    Also i tried to display the whole table as Hierarchial
        lr_table_settings->set_display_type( if_salv_wd_c_table_settings=>display_type_hierarchy ).
    For both the possibilities the result is not as desired.
    Regards,
    Arti.

    Hi Aleem,
    The link u have provided gives the solution for the Table.
    I want the implementation for ALV.
    Also my requirement is that the first column of the ALV should be hierarchial.
    On expanding the table cell of first column one more table should open of same type.
    This way user can navigate to three diffierent database tables.
    The tree is populated at runtime with the data. So the depth of branches is unknown at design time.
    I hope the requirements are clear to u now.
    Thanks and Regards,
    Arti.

  • SQL LOGIC - How to accept USER input and use that data in SQL Logic?

    Hello Experts
    Can anyone of you please explain in detail how to acheive the above task am a begginner, it would be great help for me.
    Thanks in Advance.

    Hi,
    You mean to say, you need to use inputs from Data manager Prompts in your Script Logic.
    From Help File
    You can use the EvDTSModifyPkg task to dynamically pass a text string to logic in Data Manager.  For example, a user who wishes to dynamically pass a text string representing a year (which is a portion of the *XDIM_MEMBERSET instruction) could use the following steps:
    Using the EvDTSModifyPkg task, prompt for the year, i.e., PROMPT(TEXT,%TEXT%,"select a year")
    Pass the returned %TEXT% to the FormulaScript of the RunLogic task as follows: TASK(RUNLOGIC,FORMULASCRIPT,"*FUNCTION MYYEAR=%TEXT%u201D)
    In the Data Manager logic, use the dynamically created function as follows: *XDIM_MEMBERSET TIME=MYYEAR.INPUT.
    The logic name in the RunLogic task must be specified with the .LGF extension to enforce its validation at run time.
    BPC NW 2.0 Version Works differently.
    Hope this Helps,
    Kranthi

  • Replace Values for a Col under a Table using Replace Function in Sql Query

    Hi all
    I have a Custom Table by Name RESP_TABLE which stores the Responsibility Names under the Column RESPONSIBILITY.
    The Sample Value for this col is as follows :
    PF <CNTRY> Gl Analyst <CCY>.
    This <CNTRY> Stands for Country Short Name
    and <CCY> Stands for Currency.
    The <CNTRY> & <CCY> should be passed as a parameter at the run time.
    Based on the value given at the run time it should change accordingly.
    For example
    PF <CNTRY> Gl Analyst <CCY>
    <CNTRY> Value passed at runtime : BE
    <CCY> Value passed at runtime : CAD
    So the resulting value should be as follows :
    PF BE Gl Analyst CAD.
    I had already used the query given below :
    SELECT REPLACE(RESPONSIBILITY,'<CNTRY>','&MARKET') FROM RESP_TABLE.
    This works fine for Country Code alone but not for currency.
    I need both the Country Code and Currency Code to be changed to the respective values given at the runtime.
    Could anybody please help me on this ?
    Regards
    Nakul Venkataraman.

    Hi Nakul,
    Why not just adding another REPLACE to what you still have achieved? :)
    Regards,
    Guido

  • How to create a clickable Table of contents using Crystal Reports 8.5

    How to create a clickable Table of contents using Crystal Reports 8.5. I was able to create the table of contents using subreport and temporary table. but not able to link to the pages.
    how to make it clickable ?
    -Vivek

    Hi Vivek,
    To you may create on demand sub report.
    In main report only the link will be shown when you click on the link the sub report will be opened in a new tab.
    It can be placed in a Group header and to show the data for that particular group only.
    Click on the Help menu in the crystal Reports Designer and open the Crystal Reports Help
    Go to Index tab and type in subreport
    Select Creating On demand you will get lot of information on that.
    Please let us know if that is enough to solve your problem
    Regards,
    Aditya Joshi

  • How to create a matrix report on Apex 4.1

    Hi all.
    I need to create a report similar to this one:
    Jan Feb Mar .....
    Product Category
    Category One 999 999 999
    Category Two 999 999 999
    On a reporting tool like Oracle Reports, this is call a matrix report which can be easily created: just one simple query , select a matrix report type, compute summary values for row /column and grand total, and that is.
    How would one implement this on Apex 4.1???
    Have a couple of ideas:
    - Populate temporary table with columns corresponding to month.
    - Create a procedure that return a collection and use that as a source for report.
    - Etc.
    What other options do i have ...?
    Thanks in advance ...!

    Hi all,
    I did create a matrix report using the pivot function and some interesting settings in APEX. So far it is only does display data. I did not find a way yet(?) to alter the data in the same matrix.
    The data is based on a simple set of tables about planning. The end result does look something like the matrix below. Note: the dashes are just there to make the matrix look like a matrix on this forum.
    Resource 13-08 20-08 27-08 03-09 10-09 17-09 24-09
    Angelo-----25-----22-----12-----10------------------------
    John---------8-----22-----36-----22------------------------
    Marit-----------------5-----40-----36-----24-----12-----10
    The resources (Angelo, John and Marit) are being registered in the following table:
    CREATE TABLE EVP_RESOURCES
    RSS_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(25 BYTE) NOT NULL
    The date periods (13-08 till 24-09) are being registered in the next table:
    CREATE TABLE EVP_DATA_POINTS
    DPT_ID NUMBER(10,0) NOT NULL,
    DATA_POINT_DATE DATE NOT NULL,
    V_DATA_POINT_DATE_FORMATED VARCHAR2(75 BYTE) GENERATED ALWAYS AS (TO_CHAR("DATA_POINT_DATE",'dd-mm')) VIRTUAL VISIBLE
    The virtual column (v_data_point_date_formated) is not needed. You can use this virtual column or format the column in multiple places.
    The available units are being registered in the intersection table below:
    CREATE TABLE EVP_RESOURCE_PLANNING
    RPG_ID NUMBER(10,0) NOT NULL,
    DPT_ID NUMBER(10,0) NOT NULL,
    RSS_ID NUMBER(10,0) NOT NULL,
    UNITS NUMBER(10,0)
    The data is being displayed in APEX in a report region of type "SQL Query (PL/SQL function body returning SQL query)". And the following option has to be switched on "Use Generic Column Names (parse query at runtime only)".
    This does give a restriction on the number of columns which can be used. You can however change the number of columns in the field "Maximum number of generic report columns:" to a high number. So in most cases this is no issue at all.
    In the Region Source I did put the following code:
    begin
    return 'select *
    from ( select rss.name "Resource"
    , v_data_point_date_formated
    , rpg.units
    from evp_resources rss
    , evp_data_points dpt
    , evp_resource_planning rpg
    where rpg.dpt_id = dpt.dpt_id
    and rpg.rss_id = rss.rss_id
    pivot (sum(units) for v_data_point_date_formated in (' ||
    evp_pkg_dpm.f_dynamic_pivot_in ||
    order by 1';
    end;
    The function evp_pkg_dpm.f_dynamic_pivot_in does return a string which is based on the number of rows in the table evp_data_points. In my case this string is: '13-08' as "13-08",'20-08' as "20-08",'27-08' as "27-08",'03-09' as "03-09",'10-09' as "10-09",'17-09' as "17-09",'24-09' as "24-09". If you ommit the 'as "..."' you do get quotes in your headings.
    Enjoy and regards,
    Jurgen
    PS: let me know if something is missing or not clear!
    Edited by: user553427 on Aug 17, 2012 5:46 AM (Query has been made more simple and I build up the header differently)

  • How to create the custom table?

    Hi, how to create the custom table and how to integrate the table with defferent R/3?
    my requiremnt is i have to create the two tables and those i have to integrate with the existed R/3 and using those R/3 i have to update my custom tables .....can give me some idea?
    Tks
    DPk

    how to create the custom table
    There are two approach in creating a table.
    1. Bottom-up approach
    2. Top-down approach.
    Both are valid and you can choose which approach is suitable for you. I always use the bottom-up approach. Here are the steps to create the tables with this approach.
    1. SE11 will take you to the DDIC and enter the name of the new table to be created. Let us say Zname. Click create.
    2. Enter the short discription of the table and enter the field of the table. If it is primary key and you have to check the box.
    3. Enter the data element and double click it, you will be asked to save and will take you to data element discription page. Enter the short discription of the data element and enter the information of domain like the length of field and type of field.
    4. If you wanted to use the existing domain then its fine, or else, you have to create one. Enter the domain name in the data element page and double click it. Page will ask to save and jump to domain creation page.
    5. In the domain page, you have to save the information which you have already given in the data elements page and check it. Before going to data element page, you have to activate the domain.
    6. Go to data element page and save, check and activate.
    7. Go to main table page and save, check, and activate.
    8. Also, you have to save the technical settings of the table.
    The table is now ready for operation. You can use it in your program or you can use it to enter information.
    Check table: It is the table which will have all the information about the Foreign keys which are the primary keys in the check table.
    It can be created by creating the foreign key from the main table. Click foreign key in the main table and it will take you to a page which will ask for table name and field to which foreign key relation has to be associated. Enter the information and you can create the check table automatically.
    SM30 is used for maintenance of the table, that is to realease the errors occured during the creation of the table.
    how to integrate the table with defferent R/3
    Transport the Table to the another server/client/qas/prd
    Kanagaraja L

  • How to create a temp table in the memory, not in disk?

    in sql server, you can create a temp table in the memory instead of disk,
    then you can do the insert, delete,update and select on it.
    after finishing, just release it.
    in Oracle,
    I am wonderfing how to create a temp table in the memory, not in disk?
    thanks,

    Thanks for rectifying me Howard.
    I just read your full article on this too and its very well explained here:
    http://www.dizwell.com/prod/node/357
    Few lines from your article
    It is true, of course, that since Version 8.0 Oracle has provided the ability to create a Keep Pool in the Buffer Cache, which certainly sounds like it can do the job... especially since that word 'keep' is used again. But a keep pool is merely a segregated part of the buffer cache, into which you direct blocks from particular tables (by creating them, or altering them, with the BUFFER POOL KEEP clause). So you can tuck the blocks from such tables out of the way, into their own part of the buffer cache... but that is not the same thing as guaranteeing they'll stay there. If you over-populate the Keep Pool, then its LRU mechanism will kick in and age its contents out just as efficiently as an unsegregated buffer cache would.
    Functionally, therefore, there can be no guarantees. The best you can do is create a sufficiently large Keep Pool, and then choose the tables that will use it with care such that they don’t swamp themselves, and start causing each other to age out back to disk.
    Thanks and Regards

  • How to create variant for table/view ?

    Hi,
    When I go through SM30, I find a radio button called variant. I don't know the effect.
    Can anyone tell me how to create variant for table / view ?
    I want to know when we need to create variant for table/view.
    Best regards,
    Chris Gu

    hi ,
    Whenever you start a program in which selection screens are defined, the system displays a set of input fields for database-specific and program-specific selections. To select a certain set of data, you enter an appropriate range of values.
    For further information about selection screens, refer to Selection Screens in the ABAP User's Guide.
    If you often run the same program with the same set of selections (for example, to create a monthly statistical report), you can save the values in a selection set called a variant
    Procedure
    To create a new variant:
           1.      On the ABAP Editor initial screen, enter the name of the program for which you want to create a variant, select Variants, and choose Change.
           2.      On the variant maintenance initial screen, enter the name of the variant to be created.
    Note the naming convention for variants (see below).
           3.      Choose Create.
    If the program has more than one selection screen, a dialog box for screen assignment appears. The dialog box does not appear if the program only has one selection screen. The selection screen appears in this case.
           4.      If there is more than one selection screen, select the screens for which you want to create the variant
    5.      Choose Continue.
    The (first) selection screen for the report appears.
    If your program has more than one selection screen, use the scroll buttons in the left-hand corner of the application toolbar to navigate between them and to fill the fields with values. If you keep scrolling forwards, the Continue button appears on the last selection screen.
           6.      Enter the desired selection values, including multiple selection and dynamic selection.
           7.      Choose Continue.

  • How to create the sales order using BAPI's ....?

    Hi Guru's,
    could you please provide how to create the sales order using BAPI's .....i need step by step process and please provide the details from scratch....basically  i don't have basic knowledge on this....please provide required inputs ....:)
    thanks in advance
    Srinivas......

    Hi Guru's thanks for your inouts and your valuble time...
    please find the program logic below...
    *& Report  ZAREPAS30
    REPORT  zarepas30.
    DATA : gs_vbeln                   TYPE  vbak-vbeln,
           gs_order_header_in         TYPE  bapisdhd1,
           gs_order_header_inx        TYPE  bapisdhd1x,
           gt_order_items_in          TYPE  STANDARD TABLE OF bapisditm,
           gwa_itab1                  TYPE  bapisditm,
           gt_order_items_inx         TYPE  STANDARD TABLE OF bapisditmx,
           gwa_itab2                  TYPE  bapisditmx,
           gt_order_partners          TYPE  STANDARD TABLE OF bapiparnr,
           gwa_itab3                  TYPE  bapiparnr,
           gt_return                  TYPE  STANDARD TABLE OF bapiret2,
           gwa_itab4                  TYPE  bapiret2.
    Sales document type
      PARAMETERS: p_auart TYPE auart OBLIGATORY.
    Sales organization
      PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    Distribution channel
      PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    Division.
      PARAMETERS: p_spart TYPE spart OBLIGATORY.
    Requested Delivery Date
      PARAMETERS: p_edatu  TYPE edatu OBLIGATORY.
    Sold-to
      PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    Ship-to
      PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    Material
      PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    Quantity.
      PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    Plant
      PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    Start-of-selection.
      START-OF-SELECTION.
    Header data
    Sales document type
      gs_order_header_in-doc_type = p_auart.
      gs_order_header_inx-doc_type = 'X'.
    Sales organization
      gs_order_header_in-sales_org = p_vkorg.
      gs_order_header_inx-sales_org = 'X'.
    Distribution channel
      gs_order_header_in-distr_chan  = p_vtweg.
      gs_order_header_inx-distr_chan = 'X'.
    Division
      gs_order_header_in-division = p_spart.
      gs_order_header_inx-division = 'X'.
    Reguested Delivery Date
      gs_order_header_in-req_date_h = p_edatu.
      gs_order_header_inx-req_date_h = 'X'.
      gs_order_header_inx-updateflag = 'I'.
    Partner data
    Sold to
      gwa_itab3-partn_role = 'AG'.
      gwa_itab3-partn_numb = p_sold.
      APPEND gwa_itab3 TO  gt_order_partners .
    ship to
      gwa_itab3-partn_role = 'WE'.
      gwa_itab3-partn_numb = p_ship.
      APPEND gwa_itab3 TO  gt_order_partners .
    ITEM DATA
      gwa_itab2-updateflag = 'I'.
    Line item number.
      gwa_itab1-itm_number = '000010'.
      gwa_itab2-itm_number = 'X'.
    Material
      gwa_itab1-material = p_matnr.
      gwa_itab2-material = 'X'.
    Plant
      gwa_itab1-plant    = p_plant.
      gwa_itab2-plant   = 'X'.
    Quantity
      gwa_itab1-target_qty = p_menge.
      gwa_itab2-target_qty = 'X'.
      APPEND gwa_itab1 TO gt_order_items_in.
      APPEND gwa_itab2 TO gt_order_items_inx.
    Line item number.
      gwa_itab1-itm_number = '000020'.
      gwa_itab2-itm_number = 'X'.
    Material
      gwa_itab1-material = p_matnr.
      gwa_itab2-material = 'X'.
    Plant
      gwa_itab1-plant    = p_plant.
      gwa_itab2-plant   = 'X'.
    Quantity
      gwa_itab1-target_qty = p_menge.
      gwa_itab2-target_qty = 'X'.
      APPEND gwa_itab1 TO gt_order_items_in.
      APPEND gwa_itab2 TO gt_order_items_inx.
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
      EXPORTING
        order_header_in               = gs_order_header_in
        ORDER_HEADER_INX              = gs_order_header_inx
      IMPORTING
        SALESDOCUMENT                 = gs_vbeln
      tables
        RETURN                        = gt_return
        ORDER_ITEMS_IN                = gt_order_items_in
        ORDER_ITEMS_INX               = gt_order_items_inx
        order_partners                = gt_order_partners.
    Check the return table.
      LOOP AT gt_return into gwa_itab4 WHERE type = 'E' OR type = 'A'.
        EXIT.
      ENDLOOP.
      IF sy-subrc = 0.
        WRITE: / 'Error occured while creating sales order '.
      ELSE.
    Commit the work.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        WRITE: / 'Document ', gs_vbeln, ' created'.
      ENDIF.

  • How to create a booking table (make online reservation)

    Hi everyone,
    I'm just wondering if any of you know how to create a booking
    table, like a booking seat for an airplane... I have to do the
    booking table as I'm doing a Japanese Restaurant website for my
    project.. At the moment, I'm using PHP, MySQL and HTML..
    Could anyone help me, please?
    Cheers,
    Nova

    You first need to check with your host to see which type of
    server side
    scripting language they support. If they support PHP, try,
    http://www.jellyform.com/
    Shane H
    [email protected]
    http://www.avenuedesigners.com
    =============================================
    Blog:
    http://avenuedesigners.com/blog/
    Web dev articles, photography, and more:
    http://sourtea.com
    =============================================
    Proud GAWDS member
    http://www.gawds.org/showmember.php?memberid=1495
    Delivering accessible websites to all ...
    =============================================
    "mastacraft" <[email protected]> wrote in
    message
    news:f3pote$d16$[email protected]..
    > Hello,
    >
    > I need to create a booking form for a website- So wen
    they fill out form
    > for
    > bookings. Should have tab for club appearance. Magazine
    ads. Etc It needs
    > to
    > lead to this email : [email protected]
    >
    > I'm really not sure how the best way is to do this, i
    understand it's
    > probably
    > a really simple process.
    >
    > Regards,
    >

  • How to create an editable table in ADF 10g??

    Hi,
    I want to create a editable table using the Jdev 10g.. so that i can do read and write on the table. Can anyone tell me how i can create it...
    thanks in advance

    Hi,
    using ADF BC and ADF, one of the options when dragging a ViewObject from the data control palette is ADF Table. This creates an updateable table
    Frank

  • Creating database and tables using datasources in a portal application

    Hi All,
    <b>
    I have created a datasource using Visual Administrator.
    Now I want to create a database and then tables using this datasource.
    I have todo this in the portal application.
    How to create a database and then tables into this database????
    </b>
    regards
    Brahmachaitanya

    Hi,
    I have created a datasource using Visual Administrator. I am trying to connect to it in my portal application. I have written the following code...
    InitialContext iContext = new InitialContext();
    DataSource ds = (DataSource) iContext.lookup("jdbc/CustomDataSource");
    Connection connection = ds.getConnection();
    But I am getting the following connection exception....
    ResourceException in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sysadmin'.
    can anybody tell me how to go about this exception?????
    regards
    Brahmachaitanya

Maybe you are looking for

  • Photo Folders, unable to view them

    I can see photos from a particular folder,  but when I go to photo folders all I see is a black box. I am unable to see them but it will scroll thru them? I can select a random location in the black box & it will the change photos but I never know wh

  • IMac 2011 + Intel 510 SSD Performance

    Yesterday I installed Intel`s SSD 510 (120GB) in my iMac 2011 27 inch (along with a 2TB WD Caviar black) Today I did some testing and the results are somehow disappointing. It would be great if other owners of Intel`s 510 can post some benchmark resu

  • Applying  keywording to groups

    I know about adding keywording while importing but not all keywords apply to the group. So when I try to select groups of thumbnails in Library and add keywords to them it will not apply to the group but only one photo in the group. What am I doing w

  • Converting layered menu to standard format

    Hello all -- I created a Layered-format DVD for my feature film last year. I really dug the simplicity of exporting full Photoshop files/layers straight into DVDSP, but the delayed response in navigation is absolutely agonizing. I am retooling my DVD

  • How do you get the passcode on reset your iPhone

    how doyou get your passcode to reset your iphone