Query Help Preserve Column Format

I have the following query that cast the ouput into colunms, my issues is that I need to extend the query to add the returned results of Connector_1, Cache_1, EPS_1, Sent_1, Condition_1....  ANy ideas how I can accomplish this preserving the same columns?
SELECT NodeName,
MAX(CASE WHEN Poller_Name='Connector' THEN CAST(Status AS varchar) ELSE '' END) Connector,
MAX(CASE WHEN Poller_Name='Cache' THEN CAST(Status AS varchar) ELSE '' END) Cache,
MAX(CASE WHEN Poller_Name='EPS' THEN CAST(Status AS varchar) ELSE '' END) EPS,
MAX(CASE WHEN Poller_Name='Sent' THEN CAST(Status AS varchar) ELSE '' END) Sent,
MAX(CASE WHEN Poller_Name='Condition' THEN CAST(Status AS varchar) ELSE '' END) Condition
FROM
SELECT
Nodes.Caption AS NodeName,CustomNodePollers_CustomPollers.GroupName As GroupName ,CustomNodePollers_CustomPollers.UniqueName AS Poller_Name, CustomNodePollerStatus_CustomPollerStatus.Status AS Status
FROM
((Nodes INNER JOIN CustomPollerAssignment CustomNodePollerAssignment_CustomPollerAssignment ON (Nodes.NodeID = CustomNodePollerAssignment_CustomPollerAssignment.NodeID))
INNER JOIN CustomPollers CustomNodePollers_CustomPollers ON (CustomNodePollerAssignment_CustomPollerAssignment.CustomPollerID = CustomNodePollers_CustomPollers.CustomPollerID))
INNER JOIN CustomPollerStatus CustomNodePollerStatus_CustomPollerStatus ON (CustomNodePollerAssignment_CustomPollerAssignment.CustomPollerAssignmentID = CustomNodePollerStatus_CustomPollerStatus.CustomPollerAssignmentID)
WHERE
(CustomNodePollers_CustomPollers.UniqueName = 'Connector') OR
(CustomNodePollers_CustomPollers.UniqueName = 'Cache') OR
(CustomNodePollers_CustomPollers.UniqueName = 'EPS') OR
(CustomNodePollers_CustomPollers.UniqueName = 'Sent') OR
(CustomNodePollers_CustomPollers.UniqueName = 'Condition')
AND
(CustomNodePollerAssignment_CustomPollerAssignment.InterfaceID = 0)
)A
GROUP BY NodeName, GroupName

These values have similar data to what is being returned by the query above, I just want the results added to the relevant columns if I run the above query I get the result:
NodeName Connector 
Cache  EPS 
Sent  Condition
Node1               Connector1 
1  0.1 
123 Green
Theses are values that meet PollerName CASE and where clause I want to extend this so that the same/similar set of values can be returned for the PollerName
"Connector_1, Cache_1, EPS_1, Sent_1, Condition_1....  "  to the same columns but if I add these to the case and where clause all I get is doubled up columns. 
I was thinking of possibly pushing the results into a table unless there is an easier/better way?

Similar Messages

  • Row query results to column format

    I have a table as follows:
    DT | SN | Type | Value
    1/1/15 1:15 | 1 | HID | 123
    1/1/15 1:15 | 1 | VAL | 456
    1/2/15 1:15 | 1 | HID | 123
    1/2/15 1:15 | 1 | VAL | 111
    1/4/15 1:15 | 2 | HID | 222
    1/4/15 1:15 | 2 | VAL | 233
    1/5/15 1:15 | 3 | HID | 333
    1/5/15 1:15 | 3 | VAL | 344
    How to I construct a query in the below format...
    DT | SN | HID | VAL
    1/1/15 1:15 | 1 | 123 | 456
    1/2/15 1:15 | 1 | 123 | 111
    1/4/15 1:15 | 2 | 222 | 233
    1/5/15 1:15 | 3 | 333 | 344

    Hi engrforever,
    Use a PIVOT to do it. Modified the date values here:
    Create TABLE #TEMP1
    (DT datetime NULL,
    SN int NULL,
    [Type] varchar(12) NULL,
    Value int NULL
    INSERT INTO #temp1(DT, SN,Type,Value) VALUES (GETDATE()-4,1,'HID',123),
    (GETDATE()-4,1,'VAL',456),
    (GETDATE()-3,1,'HID',123),
    (GETDATE()-3,1,'VAL',111),
    (GETDATE()-2,1,'HID',222),
    (GETDATE()-2,1,'VAL',233)
    SELECT * FROM
    (SELECT DT,SN, TYPE, Value FROM #temp1) DT
    PIVOT
    ( SUM (VALUE)
    FOR TYPE IN ([HID],[VAL])
    ) PT
    DROP TABLE #TEMP1

  • Need help with column formatting (see image)

    I am trying to make a spreadsheet that calculates proportional image sizes of a fixed original size. I have it set up so you enter an original size on the left (see image below) and the spreadsheet calculates the proportional sizes on the right (in the pink column). I would like to know how to get Appleworks to re-list the proportional sizes while omitting the size pairs that = 0. Basically i want to display the proportional sizes in a new column without the zeros. This way the proportional sizes list is much smaller and easier to read.
    Thanks for any help
    morgan
    g5   Mac OS X (10.4)  
    g5   Mac OS X (10.4)  
    g5   Mac OS X (10.4)  

    Part 2
    The method indicated in your original spreadsheet, and after the refinements suggested earlier, is essentially a sieve—calculate all the values, then strain out the chaff (ie. the results with non-integer values for one or both dimensions).
    A more efficient approach is to calculate and display only the cases where both dimensions are integers.
    Here's one way. You may want to move some of the calculations and revise the formulas accordingly.
    Data Entry:
    Cells B4 and C4 are used for data entry, as in the original.
    Initial calculation: Find the LCF (largest common factor) Columns J, K, L and cell M1.
    J1: =(B$4/ROW())=INT(B$4/ROW())
    K1: =(C$4/ROW())=INT(C$4/ROW())
    L1: =IF(J1+K1=2,ROW(),"")
    Fill these three columns down to the largest short side dimension you expect to use (ie. if you'll use 39 x 78 inch original images, fill down to row 39).
    What the formulas do:
    J1: The ROW() function returns the number of the row in which the formula is located. B$4/ROW() divides the number in B4 by the number of the row. INT(B$4/ROW()) does the same division, then strips off any fractional part of the result. The second = sign is a comparison operator. The formula compares the results of the parts on each side of the sign and, if they are equal, returns TRUE (or 1), and if they are not equal, returns FALSE (or 0).
    For the example (6), the formula would return TRUE in rows 1, 2, 3 and 6, marking the four factors of 6.
    K1: Does the same, but for the number in C4.
    For the example (8), the formula returns TRUE in rows 1, 2, 4 and 8, marking the four factors of 8.
    L1: This IF() formula checks for common factors. If the cells in both columns (J and K) in a particular row contain TRUE (ie. the number of that row is a factor of both the number in B4 and the number in C4), then the sum of the two cells will be 2 (TRUE=1, FALSE=0, TRUE + TRUE = 2), and the formula will return the result of the ROW() function (ie. the number of the row). For any other result, the formula will return 'empty' (ie. what's between the two double quotes "" ).
    For the example, cells L1 and L2 will contain 1 and 2 respectively; the rest of the cells in column L will be empty.
    M1: =MAX(L1..L39)
    M1: This formula completes the search by picking off and returning the greatest number in column L, or the Largest Common Factor for the two numbers. Adjust the second cell reference in the formula to reflect the largest original image size you'll use.
    Final Calculations
    D4: =B$4/$M$1*(ROW()-3)
    E4: =C$4/$M$1*(ROW()-3)
    D4: The formula divides the number in B4 by the LCF determined above to determine the size increment that will give integer results for both dimensions of the final image(s). It then multiplies that increment by 1 in row 4, by 2 in row 5, by 3 in row 6, and so on, for as many rows as you wish. The -3 in the second part of the formula is an offset to make the value of the multiplier three less than the row in which the formula is located.
    E4: Same formula, but acting on the number in C4.
    The first five results for the example ( 6 and 8) are:
    3 4
    6 8
    9 12
    12 16
    15 20
    and for a 4 x 6 initial image:
    2 3
    4 6
    6 9
    8 12
    10 15
    Regards,
    Barry

  • String Search Query in any columns in any table in a database

    Hi All,
    I am trying to search a word which starts with 'FRA' in any columns and any tables.
    I am unable tofind what is generating a join datasets in the webservice from teh database as it is not apparent within teh 100 tables.
    I ahve looked into
    Re: How to search in all rows and all columns?
    Re: SQL Search Query - HELP!
    but none of these queries is working out for me as I am a user with no tables on its own but rather a user quering other tables.I think its a tweak on which dat adisctionary I can view
    select distinct substr (table_name, 1, 14) "Table",
    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
    from all_cons_columns,
    table
    (xmlsequence
    (dbms_xmlgen.getxmltype ('select ' || column_name
    || ' from ' || table_name
    || ' where upper('
    || column_name
    || ') like upper(''%' || 'fra'
    || '%'')'
    ).extract ('ROWSET/ROW/*')
    ) t
    order by "Table";
    running teh above query got me thsi error:
    ORA-19202: Error occurred in XML processing
    ORA-00942: table or view does not exist
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1
    19202. 00000 - "Error occurred in XML processing%s"
    *Cause:    An error occurred when processing the XML function
    *Action:   Check the given error message and fix the appropriate problem
    Any help is much appreciated
    Edited by: CrackerJack on Sep 3, 2012 5:55 PM
    Edited by: CrackerJack on Sep 3, 2012 5:55 PM

    Hi,
    CrackerJack wrote:
    Hi All,
    I am trying to search a word which starts with 'FRA' in any columns and any tables.
    I am unable tofind what is generating a join datasets in the webservice from teh database as it is not apparent within teh 100 tables.
    I ahve looked into
    Re: How to search in all rows and all columns?
    Re: SQL Search Query - HELP!
    but none of these queries is working out for me as I am a user with no tables on its own but rather a user quering other tables.I think its a tweak on which dat adisctionary I can view In all_<b>cons</b>_columns, "cons" stands for "constraints". That view only includes columns that have a constraint on them. 
    Use all_<b>tab</b>_columns if you're interested in all columns in all tables.
    select distinct substr (table_name, 1, 14) "Table",
    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
    from all_cons_columns,
    table
    (xmlsequence
    (dbms_xmlgen.getxmltype ('select ' || column_name
    || ' from ' || table_name
    || ' where upper('
    || column_name
    || ') like upper(''%' || 'fra'
    || '%'')'
    ).extract ('ROWSET/ROW/*')
    ) t
    order by "Table";You may have noticed that this site noramlly compresses whitespace.
    Whenever you post formatted text (such as query results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    When referencing a table in a differenct schema, you must qualify the table name with the owner (unless there happens to be a synonym).  For example, if you are connected as some user other than scott, and you want to use the emp table that is in the scott schema; then you can't just say "SELECT ... FROM emp;", because that would look for the emp table in yur own schema.  You have to say "SELECT ... FROM <b>scott.</b>emp;" instead.  If the table is in your own schema, then the scema name is optional.  The OWNER column in all_tab_columns gives the schema name.
    running teh above query got me thsi error:
    ORA-19202: Error occurred in XML processing
    ORA-00942: table or view does not exist
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1
    19202. 00000 - "Error occurred in XML processing%s"
    *Cause:    An error occurred when processing the XML function
    *Action:   Check the given error message and fix the appropriate problemSorry, I don't know what causes that error.
    If I use the data dictionary view cols (as in {message:id=3325696} which you cited), it runs correctly.
    If use what I though was the equivalent data dictionary view, user_tab_columns, or if I use all_tab_columns or other data dictionary views, then I get those errors.  I'm using Oracle 10.2.0.1.0.
    Edited by: Frank Kulash on Sep 3, 2012 10:45 PM
    John Spencer noticed the same problem 5 years ago.  See {message:id=1969268}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Query rows to column

    dear Friends,
    i need query row to column
    example
    1 a data1 data2 data3
    2 b data1 data2 data3
    output format
    1 2 a
    data1 data2 data3

    Please consider the following when you post a question.
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Query help with round up of dates

    Hi,
    I have a problem with my query.
    I am calculating the difference between two dates and I want to get the hours.
    The problem is that I want the following to happen:
    if the difference is x such that x > 0 it should round it up to 1 (example: x = 0.1 it should be rounded up to 1)
    if the difference is y such that y >1 it should be rounded to 1 (example y = 1.05 it should be rounded up to 2)
    i have the following query at the momet:
    select to_char(arrivaldate,'DD/MM/YYYY hh24:mi:ss') as "ARRIVAL", to_char(departuredate,'DD/MM/YYYY hh24:mi:ss') as "DEPARTURE", round(trunc(mod((departuredate-arrivaldate)*24,24),2)) as duration from stay_log;
    thanks.

    Hi,
    Format your code so that the physical appearance of the code gives some hint as to what you're doing, as I did below.
    When posting code on this forum, always type &#123;code&#125; tags at the beginning and end of formatted sections.
    Do you mean that, instead of 21, you want to use the flightid from the main query?
    If so, that's called a "correllated query". The tables in the main query (and their columns) can be reference in the sub-query, like this:
    select     flightid                         as "FLIGHT",
              select     destairport_id
              from     journey,
                   flight
              where     flight.flightid  = stay_log.flight_id   -- correlated to main query
              and     flight.journeyid = journey.journeyid
         )                              AS "AIRPORT",
         to_char(arrivaldate,'DD/MM/YYYY hh24:mi:ss')     as "ARRIVAL",
         to_char(departuredate,'DD/MM/YYYY hh24:mi:ss')     as "DEPARTURE",
         ceil((departuredate-arrivaldate)*24)          as "DURATION",
         cost                              as "COST"
    from     stay_log;Often, people give a table alias to the main query table that is being referenced in the sub-query, as shown below.
    That's only required when the table name appears in both FROM-clauses.
    select     flightid                         as "FLIGHT",
              select     destairport_id
              from     journey,
                   flight
              where     flight.flightid  = s.flight_id     -- table alias s used here
              and     flight.journeyid = journey.journeyid
         )                              AS "AIRPORT",
         to_char(arrivaldate,'DD/MM/YYYY hh24:mi:ss')     as "ARRIVAL",
         to_char(departuredate,'DD/MM/YYYY hh24:mi:ss')     as "DEPARTURE",
         ceil((departuredate-arrivaldate)*24)          as "DURATION",
         cost                              as "COST"
    from     stay_log   s     -- table alias s defined here
    ;

  • SQL Query Help - Is this possible or impossible????

    Hi guys,
    I need help with an SQL query that I'm trying to develop. It's very easy to explain but when trying to implement it, I'm struggling to achieve the results that I want.....
    For example,
    I have 2 tables
    The first table is:
    1) COMPANY create table company (manufacturer varchar2(25),
                                                          date_established date,
                                                          location varchar2(25) );My sample test date is:
    insert into company values ('Ford', 1902, 'USA');
    insert into company values ('BMW', 1910, 'Germany');
    insert into company values ('Tata', 1922, 'India');The second table is:
    2) MODELS create table models (manufacturer varchar(25),
                                                 model varchar2(25),
                                                 price number(10),
                                                 year date,
                                                 current_production_status varchar2(1) ) ;My sample test data is:
    insert into models values ('Ford', 'Mondeo', 10000, 2010, 0);
    insert into models values ('Ford', 'Galaxy', 12000,   2008, 0);
    insert into models values ('Ford', 'Escort', 10000, 1992, 1);
    insert into models values ('BMW', '318', 17500, 2010, 0);
    insert into models values ('BMW', '535d', 32000,   2006, 0);
    insert into models values ('BMW', 'Z4', 10000, 1992, 0);
    insert into models values ('Tata', 'Safari', 4000, 1999, 0);
    insert into models values ('Tata', 'Sumo', 5500,   1996, 1);
    insert into models values ('Tata', 'Maruti', 3500, 1998, 0);And this is my query:
    SELECT
            com.manufacturer,
            com.date_established,
            com.location,
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
            mod.current_production_status
    FROM
           company com,
           models mod
    WHERE
          mod.manufacturer = com.manufacturer
          and com.manufacturer IN ('Ford', 'BMW', 'Tata')
          and mod.current_production_status IN (1,0)
    ORDER BY
            mod.current_production_status DESCWhat I want the query to output is this:
    com.manufacturer        com.date_established          com.location          mod.model          mod.price             mod.year     mod.current_production_status
    Ford               1902                    USA               Escort               10000               1992          1
    BMW               1910                    Germany               -               -               -          0
    Tata               1922                    India               Sumo               5500               1998          1If current_production_status is 1 it means this particular model has been discontinued
    If current_production_status is 0 it means the manufacturer does not have any discontinued models and all are in procuction.
    The rule is only one record per manufacturer is allowed to have a current_production_status of 1 (so only one model from the selection the manufactuer offers is allowed to be discontinued).
    So the query should output the one row where current_production_status is 1 for each manufacturer.
    If for a given manufacturer there are no discontinued models and all have a current_production_status of 0 then ouput a SINGLE row that only includes the data from the COMPANY table (as above). The rest of the columns from the MODELS table should be populated with a '-' (hyphen).
    My query as it is above will output all the records where current status is 1 or 0 like this
    com.manufacturer        com.date_established          com.location          mod.model          mod.price          mod.year     mod.current_production_status
    Ford               1902                    USA               Escort               10000               1992          1
    Tata               1922                    India               Sumo               5500               1998          1
    Ford               1902                    USA               -               -               -          0                    
    Ford               1902                    USA               -               -               -          0
    BMW               1910                    Germany               -               -               -          0
    BMW               1910                    Germany               -               -               -          0
    BMW               1910                    Germany               -               -               -          0
    Tata               1922                    India               -               -               -          0
    Tata               1922                    India               -               -               -          0However this is not what I want.
    Any ideas how I can achieve the result I need?
    Thanks!
    P.S. Database version is '10.2.0.1.0'

    Hi Vishnu,
    Karthiks query helped...
    But this is the problem I am facing...
    SELECT
            com.manufacturer,
            com.date_established,
            com.location,
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
            mod.current_production_status
    FROM
           company com,
           models mod
    WHERE
          mod.manufacturer = com.manufacturer
          and com.manufacturer = 'Ford'
          and mod.current_production_status IN (1,0)
    ORDER BY
            mod.current_production_status DESCThe value of:
    and com.manufacturer = 'Ford'will be dependent on front end user input....
    When I run the query above I get all the rows where current_production_status is either 1 or 0.
    I only require the rows where current_production_status is 1.
    So if I amend it to look like this:
         and mod.current_production_status = 1This works....
    BUT if a user now passes in more than one manufacturer EG:
    and com.manufacturer IN ('Ford', 'BMW')The query will only return the one row for Ford where current_production_status is 1. However because BMW has no models where current_production_status is 1 (all 3 are 0), I still want this to be output - as one row....
    So like this:
    com.manufacturer        com.date_established          com.location          mod.model          mod.price             mod.year     mod.current_production_status
    Ford               1902                    USA               Escort               10000               1992          1
    BMW               1910                    Germany               -               -               -          0So (hopefully you understand), I want both cases to be catered for.....whether a user enters one manufacturer or more than one...
    Thanks you so much!
    This is really driving me insane :-(

  • Query on database column not working

    Hi
    i have a block which has around 40 columns.the block is based on a table which has more than 20000 records.When i try 2 make query on a Database column in Enter-Query mode its not working.It fetching all the records instead of the respective records
    THe block property is said to yes
    i have even set the query allowed,only propery of the column to YEs
    Can any one help me out of this??? do i need to set any other property???

    Thanks a lot for james and THomas and to all. The error is that i have missed the bracket for OR in my where condition ...Now im able to query all the columns.
    Thanks very much...
    I have one more doubt .i have a requirement in which when the user goes to the child block and makes a query is it possible to bring the associates parent records..wht code or trigger we need to rite ?
    normally we do for parent block when we query we populate the child. is this can be done?

  • Spacing at the end of each column in 3 column format

    I am copying text with footnotes from a word file into Pages. When the text is pasted into the three column format some of the columns are really short. They don't even make it half way to the start of the foot notes on the bottom of the page. How can I make the columns extend to the start of the foot notes on all of the pages? Please Help. Thank you.

    No luck there- I had actually already tried that. The only thing that has worked so far, after many attempts, is to erase the footnotes and reinsert them. (So I'm guessing all the issues stem from pasting over from Word.) If there's an easier way, I'd love to find it since this is a rather long paper with lots of footnotes. (And I can't just leave the document in Word...based on my formatting tries and research, it's not even really capable of doing the footnotes the way I'd like them to be.)

  • Result of an SQL query as a Column name of another query

    Hi Friends,
    Can we use a result of a SQL Query as a column name of another table to retrieve data. If so please help me.
    For eg :
    I have a table where is store numbers;
    select col1 from table1 where col1='5';
    and i have another table where .. this value of col is a column name..
    select ( select col1 from table1 where col1='5') from table2;
    Thanks in advance.

    Hi,
    ORAFLEX wrote:
    Hi Friends,
    Can we use a result of a SQL Query as a column name of another table to retrieve data. If so please help me.
    For eg :
    I have a table where is store numbers;
    select col1 from table1 where col1='5';
    and i have another table where .. this value of col is a column name..
    select ( select col1 from table1 where col1='5') from table2;
    Thanks in advance.Do you really mean that?
    select col1 from table1 where col1='5';That query will always return either '5' or nothing. Whatever you're trying to accomplish with that, you can do with an EXISTS query.
    Perhaps you meant to reference two different columns in that query:
    select col1 from table1 where col2='5';In that case, sorry, no, you can't do that without resorting to dynamic SQL.
    If the same column is used throughout the query (but could change every time you run the query), then the dynamic SQL might be pretty easy. In SQL*Plus, for example, you could use substitution variables, defined in another query at run-time.
    If there are only a few possible values that the sub-query could possibly return, and you know what they all are, then you can fake a dynamic query like this:
    SELECT     CASE     ( SELECT  col1
                FROM       table1
                WHERE       col2     = '5'
              WHEN  'BONUS'     THEN  bonus
              WHEN  'COMM'     THEN  comm
              WHEN  'SAL'     THEN  sal
         END     AS col1
    FROM     table2
    ;Sorry to give such a vague answer, but it's the best I can do with the information I have.
    It would help if you posted a little sample data (CREATE TABLE and INSERT statments for both tables), and the results you want to get from that data. If you want to pass a parameter to the query, give the results you want for a couple of different parameters.

  • How do I maintain column formatting when converting from PDF to Excel?

    How do I maintain column formatting when converting from PDF to Excel? All info is no longer on the lines or in the columns they started out being in? Any help would be appreciated.

    Sara,
    Perhaps I am expecting too much from Adobe ExportPDF. The reason I subscribed to this service, for which I pay a yearly fee, was that I need a way to  convert scanned and digital documents to Word &/or Excel. I read the link you included but to be candid the more I tried to understand what was written the more confused I got. The process should not be this difficult. Currently I am using a NEAT scanner to create PDF documents of whatever I scan. After I changed the OCR setting on Adobe ExportPDF the output was much better but not to the point it was usable as it was. Information that appears to be lines and columns are sometimes not recognizing two columns and just putting them together in one. Obviously not usable. The other thing it does is bunch numbers that appear in a column that are just a bunch of numbers that I have no way of fixing. 
    Please let me speak to someone who can help me. Right now I not getting anything of value in my paid subscription.

  • Creating Query with dynamic columns to show results

    Hi experts,
    I need to know how to create a query with dynamic columns. Meaning, I don't want to create a query with fixed columns representing the 12 periods of the fiscal year to show me actuals as the fiscal year proceeds.
    For example, if I am currently in the middle of period 3 (March) of a fiscal year, when I execute the query, I need it to automatically only show me the 'Actuals' for periods 1 and 2, without seeing the columns from periods 3 to 12 showing blank.
    Then when I am in the middle period 5 (May) the query should ONLY show me the columns for periods 1 to 4 'Actuals', no results should be shown for periods 5 to 12 yet, and I don't want to even see blank columns for period 6 to 12.
    How do I define my columns, to achieve this.
    Maximum points will be awarded.
    Thanks Everyone.

    Hi Josh,
    I'm having a little difficuluty understanding what should be included in my restricted key figures.
    The time characteristics that I have available to use are:
    0FISCPER3 (posting period)
    0FISCYEAR (fiscal year), currently using SAP EXIT to default current fiscal year.
    0FISCVARNT (fiscal year variant).
    In addition, I have the following characteristics available to be used in the columns:
    Value type (10)
    version (currently I'm using variable for it)
    Currency type (020)
    Currency (USD).
    Can you explain what my restricted key figure should be based on and how it should look.
    I tried to create a restircted key figure using 0AMOUNT, and 0FISCPER3. For 0FISCPER3  I created a range from 1 to previous period (using SAP EXIT that supplied previous period).I also had value type, version, currency type, and currency included in that restricted key figure.Then when I tried to drag 0FISCPER3 under the restricted key figure once again, it wouldn't let me, probably because I've already used 0FISCPER3 in the restricted key figure.
    Please let me know if my explanation is not clear.
    Your step by step help would be great.
    Thanks
    Edited by: Ehab Mansour on Sep 23, 2008 2:40 PM

  • Spatial query help

    Can anyone help, I'm trying to run the following query but all columns are returning nulls. I know there is data for the first 2 tables but the third table contains no data. In a live situation sometimes the table will contain data, sometimes it wont, how can I get it to the return the data that is there? Normally would do an outer join but can you do that with the sdo_relate operator? Tried various nvl and decodes too.
    thanks !
    select p.ident PRN, wqz.ident WQZ_ID, nvl(ced.ident,'dont know')
    from property p, wqzone wqz, ced
    where sdo_relate(wqz.geometry,p.geometry,'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE'
    and sdo_relate(ced.geometry,p.geometry,'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE'
    and p.ident = 765432

    If you want to join the whole "property" table, you can try to run the select below.
    I don't know how many rows you must quering. On my tables this query works fine up to 1000 records.
    good job, regards
    Carl
    select
    p.ident PRN, wqz.ident WQZ_ID, nvl(ced.ced_ident,'dont know')
    from property p, wqzone wqz
    , (select B.ident p_ident, A.ident ced_ident from ced A, property B
    where sdo_relate(A.geometry, B.geometry,
    'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE') ced
    where p.ident = ced.p_ident (+)
    and sdo_relate(wqz.geometry,p.geometry
    ,'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE'

  • Report Writer Row and Column Format

    Hi
    Was wondering if there is a possible solution to this :-
    Understand that column format is controlled by format groups. This means that all figures in the same column will take the same format (such as scaling and decimal place).
    Scenario is ->
                        Colunn #1 -> column set as displaying no decimal point       
    Rev                  120
    OP                      5
    OP margin %     4.2 -> how to set this to 1 decimal point. Any formula syntax that I can use?
    Regards.

    Hi Vinay,
    Based on my research, freezing row and column headers are different in table and matrix.
    In a table, if we want to freeze column header, we should make the changes in the first Static row group in Row Groups pane with Advanced Mode as you said. If we want to freeze row header, the table should have a group ahead, then we can enable “Repeat header
    rows on each page” and “Keep header visible while scrolling” options in Row Headers in Tablix Properties dialog box.
    In a matrix, if we want to freeze column header, we can enable “Repeat header columns on each page” and “Keep header visible while scrolling” options in Column Headers in Tablix Properties dialog box. If we want to freeze row header, we can enable “Repeat
    header rows on each page” and “Keep header visible while scrolling” options in Row Headers in Tablix Properties dialog box.
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • About Query Data Source Columns property

    Hello everyone,
    I'm new to Oracle Forms version 10.1.0.2.
    When I create a data block based on a table using Data Block Wizard, the block's Query Data Source Columns property is automatically populated with column definition entries corresponding to the columns of the base table.
    I tried making changes to these entries, for example by changing the data types to wrong data types or even deleting them, and I found that those changes had no effect on the block at all. The form was still working as I wanted.
    Please explain what is exactly the role of the block's Query Data Source Columns property.
    Thank you very much.
    p.s: The F1 key help says "The Query Data Source Columns property is valid only when the Query Data Source Type property is set to Table, Sub-query, or Procedure". So, please explain in each context of Query Data Source Type.

    p.s: The F1 key help says "The Query Data Source Columns property is valid only when the Query Data Source Type property is set to Table, Sub-query, or Procedure". So, please explain in each context of Query Data Source Type.
    IMHO those properties are very self-explaining: It is the data source of the block, or in other terms: how it is populated.
    Table means the data block is based on a table and subsequently will be populated by
    select col1, col2, col3 from your_table
    With sub-query the block will be populated with your subquery; forms will issue
    select col1, col2, col3 from (
      -- this is your subquery
      select col1, col2, col3 from tab1, tab2 where [....]
    With Procedure in short you'd have a stored procedure which returns a ref cursor and the block will be populated by the ref cursor.
    As for your question about the name: this actually should matter; the default is NULL which means that there needs to be a column which has the exact name as the item so in the above sample with table the item associated with your_table.col1 should be named col1. If it isn't the property should be named like the column. If this property also doesn't reflect the name this shouldn't work IMO.
    cheers

Maybe you are looking for