Multiple columns are specified in an aggregated expression containing an outer reference...

Hi guys, probably I am still sleeping, but why in the first select I retrieve 0 as bb and in the second I retrieve
Multiple columns are specified in an aggregated expression containing an outer reference. If an expression being aggregated contains an outer reference, then that outer reference must be the only column referenced in the expression.
create table car (N_state varchar(20), city varchar (20), cars int) insert into car values('California', 'Los Angeles',1000), ('Ohio', 'Columbus', 300), ('Texas', 'Austin',400), ('Florida', 'Miami',800), ('Florida', 'Orlando',200)
with cte as ( select *, (select sum(cars) from car) as bb from car) select *, cars, bb, cars/bb as cc from cte
select *, (select sum(case when c1.N_state=c2.N_state then cars else 0 end) from car c2) as bb from car c1
Many Thanks

The 0s are due to implicit conversion as operands are of type int
Modifying it as below will wok fine
;with cte as ( select *, (select sum(cars) from car) as bb
from car) select *, cars, bb, cars*1.0/bb as cc from cte
Now for second part you need to write query as below
select *, sum(cars) over (partition by N_state) as bb from car c1
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • Sorting a Collection with dynamic columns using a custom compare function for multiple columns

    I need help and ideas on how to sort a ListCollectionView.  My problem is complicated by 3 requirements-
         1. The column values contain HTML tags that needs to be removed before sorting (use custom compareFunction to strip HTML)
         2. The columns are dynamic, so dataField names are not known at compile time (need a single compareFunction for all columns)
         3. The data is used in an AdvancedDataGrid so multi-column sorting is required
    I have figured out how to solve any 2 of the 3 requirements.  However, I am having difficulties supporting all 3 requirements.
    Any help or ideas would be greatly appreciated.  Thanks.

    After playing with this some more I think I've figured out a solution.  This seems to work in initial testing.  Also, there is not a need to capture the current sort column in the headerRelease event which many offered solutions suggested.  Another benefit to this solution is that keyboard initiated sorting is handled also.  Whereas the headerRelease event is only triggered by a mouse click on the column header and special handling is required if the user uses the keyboard to access the column header.
    One point that I don't understand is how ascending/decending order is determined.  Behavior seems to be different between a single SortField versus multiple SortFields.  Notice how the compareResults are handled for the different situations.  Anyone out there know why???
     private function colSortCompareFunction(obj1:Object, obj2:Object, fields:Array = null):int{
         var compareResults:int = 0; 
         var newObj1:Object = new Object(); 
         var newObj2:Object = new Object();
          // should not be a condition that is met   
         if (_dataProviderDetails.sort.fields == null)     {
              var s:Sort = new Sort(); 
              var f:Function = s.compareFunction; 
              return f.call(null, obj1, obj2, fields);     }
         // when a single column is selected for sorting   
         else if (_dataProviderDetails.sort.fields.length == 1)     {
              var firstFld:SortField = _dataProviderDetails.sort.fields[0];
              newObj1[firstFld.name] = stripHTML(obj1[firstFld.name]as String);          newObj2[firstFld.name] = stripHTML(obj2[firstFld.name]
    as String);
              compareResults = ObjectUtil.compare(newObj1[firstFld.name], newObj2[firstFld.name]);
               return compareResults;     }
         // when multiple columns are selected for sorting   
         else       {
              for each (var fld:SortField in _dataProviderDetails.sort.fields)          {
                   newObj1[fld.name] = stripHTML(obj1[fld.name]
    as String);               newObj2[fld.name] = stripHTML(obj2[fld.name]
    as String);
                   compareResults = ObjectUtil.compare(newObj1[fld.name], newObj2[fld.name]);
                    if (compareResults != 0)               {
                        if (fld.descending)                    {
                             return compareResults * -1;                    }
                        else                      {
                             return compareResults;                    }
               return compareResults;     }
    Does anyone see any problems with this solution?
    NOTE:  stripHTML(String) is a simple function using regular expression to remove HTML tags.
    Thx

  • How to filter rows where multiple columns meet criteria, ignoring rows where only some columns meet criteria

    Hi All,
    Question: How do I filter rows out of a query where multiple columns are equal to a single question mark character?
    Background: I'm using SQL 2008 R2.  Furthermore, the part of my brain that helps me create less-than-simple queries hasn't been working for the last 4 days, apparently, and now I need help.
    We have about 4,000 rows in a table.  This data set was generated from an exported report, and many of the rows in the detail table were not actual data rows but were simply "header" rows.  For those table rows, most of the columns have
    a single question mark as the value.
    Some of the detail rows have one or more question mark values, too, so it's important that these rows don't get filtered out.
    When I include criteria like "WHERE col1 <> '?' AND col2 <> '?' AND col3 <> '?' AND col4 <> '?'", all rows with a question mark value for even a single one of those columns get filtered out.  How do I filter out rows
    where all columns 1-4 contain a question mark value?
    Thanks for your help,
    Eric

    I just tried to create to create a scenario for you. Please see ig you're looking for something like this.
    Create table test_Question_mark
    RecordID INT identity(1,1),
    Col1 varchar(10),
    Col2 varchar(10),
    Col3 varchar(10),
    Col4 varchar(10),
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','?','?','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','??','?','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','??','??','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','??','??','??')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','?','?','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','test ??','??','??')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','test ?','??','??')
    --drop table test_Questio_mark
    select * from test_Question_mark
    select * from test_Question_mark 
    WHERE 
    (CHARINDEX('?', Col1,1) > 0 AND CHARINDEX('?', Col1, CHARINDEX('?', Col1,1)+1) = 0) AND 
    (CHARINDEX('?', Col2) > 0 AND CHARINDEX('?', Col2, CHARINDEX('?', Col2,1)+1) = 0) AND 
    (CHARINDEX('?', Col3,1) > 0 AND CHARINDEX('?', Col3, CHARINDEX('?', Col3,1)+1) = 0) AND 
    (CHARINDEX('?', Col4,1) > 0 AND CHARINDEX('?', Col4, CHARINDEX('?', Col4,1)+1) = 0) 
    --drop table test_Questio_mark
    I hope above solution will help.
    Thanks!
    Ashish.

  • Multiple columns in migrating MS Access

    Migration workbench Access 97 -> Oracle 8.1.6
    During capture of source data, multiple columns are generated for each table. In fact, columns of one table are duplicated on all others tables ==> building of Oracle model hangs for violation of unique constraint.
    Thanks for your help to fix it.
    null

    DatabaseMetadata.getColumns() if you want to get the data on some table in the DB
    or
    ResultSetMetaData.getColumnCount() and ResultSetMetaData.getColumnName() if you want to get the data on a result returned from some query.

  • USING MULTIPLE CONTROLLING AREA in the column

    Dear Experts,
    As per my requirement i need fetch the data from multiple controlling areas in to one report. please let us know how many ways are there? can i able to use controlling are in the column of the report. when i try to select the controlling area is not appearing in the coumn and it is appearing only in the gene

    Hi,
    You can select multiple Controlling area Please try with following steps.
    Maintain variant
    Click on attributes.
    Environment > Maint.sel.varables.
    Click on Display/Change.
    Create new Parameter.
    Maintain selection options to new parameter.
    Save and back.
    Select "T" in selection variable against Field name :Controlling Area.
    Select the selection variable(Newly created Parameter)
    Regards
    Mahesh

  • I am trying to sync Go Rock TRMS03SR Bluetooth Portable 3D Surround Speakers with my Airport Express or iTunes So I can play Music in Multiple rooms. I have a WiFi network, my living room speakers are connected directly to Airport Express.

    I am trying to sync Go Rock TRMS03SR Bluetooth Portable 3D Surround Speakers with my Airport Express or iTunes So I can play Music in Multiple rooms. I have a WiFi network, my living room speakers are connected directly to Airport Express, so how can I get the wireless bluetooth speakers to play at the same time in my bedroom?

    Did you ever get this to work?  My guess is that the speakers are out of bluetooth range at that distance.

  • Multiple Column Header in Report (BEx and Web Reporting)

    Hi All,
            I've a requirement where my reports is having multiple column header.
       To be precise the column header is further divided into many sub-columns (upto 4 levels).
    Structure cannot help in this case since we have more than 2 such columns and we are using web reporting as well.
    Here is how it looks
                             <b>Header-A</b>
    Header-B1   |   Header-B2   |   Header-B3    |  Header-Bn
    Hdr-C1 |Hdr-C2 |Hdr-D1 |Hdr-D2 |Hdr-E1 |Hdr-E2 |Hdr-Fn..
    The above is a sample header structure.
    This report will be a Web Based report and I need to know whether its possible to do it in BEx also.
    We are not using Crystal Reports.
    If there is any document related to this, please mail to
    [email protected]
    Thanks & Regards,
    Chandran Ganesan

    Hi Chandran,
    I hope i am getting your problem right.
    If your
    Header-B1 | Header-B2 | Header-B3 | Header-Bn
    Hdr-C1 |Hdr-C2 |Hdr-D1 |Hdr-D2 |Hdr-E1 |Hdr-E2 |Hdr-Fn..
    are a set of key figures, then there is an option.
    For example:
    You drag Header-B1,Hdr-C1 |Hdr-C2
    into column section.Right click on Hdr-C1, Hdr-C2 and select down under. So your Hdr-C1, Hdr-C2 will be under
    Header-B1.
    Like wise drag Header-B2,Hdr-D1,Hdr-D2
    Right click on Hdr-D1,Hdr-D2 and say Down under and these two will fit below Header-B2.
    You can repeat the above steps for Header-B3... Header-Bn
    The output will be same as the one you have specified above.
    Hope it helps,
    Regards,
    Parth.

  • How to Query Multiple Fields from different Tables using Toplink Expression

    Hi,
    I am trying to prepare an Oracle Toplink Expression to qurey the multiple columns of different tables. the query as following. Please can anyone help?
    SELECT CYCLE.CYCLE_ID,
    CYCLE.ASPCUSTOMER_ID,
    CYCLE.FACILITYHEADER_ID,
    CYCLE.ADDUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME ADDUSERNAME,
    CYCLE.ADDDATE,
    CYCLE.LASTUPDATEUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME LASTUPDATEUSERNAME,
    CYCLE.LASTUPDATEDATE,
    CYCLE.CYCLENAME,
    CYCLE.CYCLENUMBER,
    CYCLE.DESCRIPTION
    FROM CYCLE,ASPUSER ASP
    WHERE CYCLE.ADDUSER = ASP.ASPUSER_ID
    and then i want to send that expression to readAllObjects method as a parameter
    Expression exp = (..............this is the required qurey expression...................)
    Vector employees = session.readAllObjects(getClass(), exp);
    thanks,

    You havent given any information on the mapping between Cycle and Asp. I presume there is a one to one mapping between them. Also it appears there is no "WHERE" clause to limit the number of cycles being retrieved. If that is the case then I presume you want to load all cycles in the system.
    Thats just a clientSession.readAllObjects(Cycle.class). If you have indirection turned on the Asp should get loaded when you do a cycle.getAsp().
    I presume that SQL you posted loads all the columns of CYCLE and ASP. If you are interested in a subset of CYCLE or ASP then you should do a ReportQuery or partial object read.
    Hi,
    I am trying to prepare an Oracle Toplink Expression
    to qurey the multiple columns of different tables.
    the query as following. Please can anyone help?
    SELECT CYCLE.CYCLE_ID,
    CYCLE.ASPCUSTOMER_ID,
    CYCLE.FACILITYHEADER_ID,
    CYCLE.ADDUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME ADDUSERNAME,
    CYCLE.ADDDATE,
    CYCLE.LASTUPDATEUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME
    LASTUPDATEUSERNAME,
    CYCLE.LASTUPDATEDATE,
    CYCLE.CYCLENAME,
    CYCLE.CYCLENUMBER,
    CYCLE.DESCRIPTION
    FROM CYCLE,ASPUSER ASP
    WHERE CYCLE.ADDUSER = ASP.ASPUSER_ID
    and then i want to send that expression to
    readAllObjects method as a parameter
    Expression exp = (..............this is the required
    qurey expression...................)
    Vector employees = session.readAllObjects(getClass(),
    exp);
    thanks,

  • Counting Occurences over multiple columns

    I have searched the forums and found how to calculate the number of occurrences of a word in a single column.
    I am working on a sales project and I need to calculate the number of occurrences for a specific sales agent in multiple columns. Then a total of the sales next to the occurrences
    Column 1 will be the sales agent for a home buyer.
    Column 2 will be the sales agent for a home seller.
    I need to find out how many times a specific agent represents both buyers and sellers.
    Then I need a total of all the sales for each of the agents.
    I have very large tables with multiple categories for each sale.
    Yvan you seem to be the guru.
    Please help.
    All the best,
    Will

    Will,
    Jerry has given you a good solution in general terms but there are some ambiguities in your question.
    For example, your question suggests there is transaction amount column, as one might expect, but did not specify if these amounts are listed in separate buyer/seller columns. The solution below assumes they are in a single column.
    An auxiliary column (hidden) was added to the Data Table to determine whether or not an agent represented both buyer and seller. The agent's name appears in this column if he/she did, and the formula is:
    =IF(OR(Sell Agt="",Buy Agt=""),"",Sell Agt)
    The Summary table raises the question of whether the agent's amount is doubled when he/she represents both buyer and seller. Here again, an assumption was made, namely, that it does not. If this is incorrect, the last segment (after the "-" sign) of the formula below can be dropped:
    =IF(A="","",SUMIF(Sales Data :: Sell Agt, A, Sales Data :: Trans Amt)+SUMIF(Sales Data :: Buy Agt, A, Sales Data :: Trans Amt)-SUMIF(Sales Data :: 'Buyer & Seller Rep', A, Sales Data :: Trans Amt))
    And finally, the number of times an agent represented both buyer and seller:
    =IF(COUNTIF(Sales Data :: 'Buyer & Seller Rep', A)=0,"",COUNTIF(Sales Data :: 'Buyer & Seller Rep', A))
    I hope this represents your situation and that it answers your questions.
    pw

  • Mapping multiple columns of a table to single dimension using odi

    Hi John,
    Can we map multiple columns of a table to a single dimnesion?
    For example, in RDBMS, for the employee details, Grade position etc will be in different columns, and in Planning these would be as members of one dimension.
    So while loading data from oracle to essbase can we map these multiple columns to single dimension?
    If yes how?

    Hi,
    In your staging area/target you can concatentate the columns.
    So in your interface and on your target datastore, pick the column which is going to hold the details of the concatenation.
    Then in the expression editor use the CONCAT function, or you could use ||
    eg CONCAT(<sourceCol1>, <sourceCol2>)
    or <sourceCol1> || <sourceCol2>
    obviously you need to change the information between <sourceCol1> to your source datastore column
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Multiple Column Sorting in iTunes

    I have seen many conversations around the edges of this, but no answers.  I am curious if it is possible to configure a custom sort in iTunes involving multiple columns. 
    Here is what I would like to end up with - Artist; Sort Show (where I have stored the release date); Album; Disk Number; Track Number.  Seeing my albums in chronological order is the way I always sorted physical albums, I would like to store my virtual ones the same way.  iTunes allows me to use Album by Artist and then sort by Sort Show, but this then displays the tracks in alphabetic order by name! 
    Identifying multiple sort columns (as in Excel) would be ideal.  Thanks for any help you can provide.
    Dave

    It is a database internally, and there are some multivalued sorts, but as users we don't get to specify custom sort orders. Album by Artist is more properly Album by Album Artist and in pseudo-SQL it would go something like this.
    SELECT * FROM Selection ORDER BY SortAlbumArtist, SortAlbum, Disc# , Track#
    Where there is no SortAlbumArtist it is inferred from the first non-empty value of AlbumArtist, SortArtist or Artist.
    Where there is no SortAlbum it is inferred from Album.
    The Disc# & Track# sorts place empties last.
    Presumably the designers think they've included useful options and adding nested sorting features would be too complicated, but you can make suggestions via iTunes Feedback.
    tt2

  • ALV: How to sort multiple columns?

    Hi all,
    Good morning!
    I have a requirement to sort multiple columns in ALV. I did a search and tried with following codes:
    data: lo_config_alv  type ref to cl_salv_wd_config_table.
    lo_config_alv->if_salv_wd_table_settings~set_multi_column_sort( value = abap_true ).
    But I still can not sort for multiple columns.
    Please guide me how to do that.
    Thanks,
    Khanh

    Hello,
    If you want to sort ALV by multiple fields, then you have to create sort rule for each field and set sort position for each field to specify the sequence in which you want to sort multiple columns.
    Here is a sample code:
    * Sort rows by PRICE descending
      DATA: lr_field1 TYPE REF TO cl_salv_wd_field.
      DATA: lr_rule1 TYPE REF TO CL_SALV_WD_SORT_RULE.
      lr_field1 = lv_value->if_salv_wd_field_settings~get_field( 'PRICE' ).
      lr_field1->if_salv_wd_sort~create_sort_rule( EXPORTING sort_order = if_salv_wd_c_sort=>sort_order_descending
                                                   RECEIVING value = lr_rule1 ).
      lr_rule1->set_sort_position(  2 ). "set the sort position to 2
    * Sort rows by seatsmax descending
      DATA: lr_field2 TYPE REF TO cl_salv_wd_field.
      DATA: lr_rule2 TYPE REF TO CL_SALV_WD_SORT_RULE.
      lr_field2 = lv_value->if_salv_wd_field_settings~get_field( 'SEATSMAX' ).
      lr_field2->if_salv_wd_sort~create_sort_rule( EXPORTING sort_order = if_salv_wd_c_sort=>sort_order_descending
                                                              RECEIVING value = lr_rule2 ).
      lr_rule2->set_sort_position( 1 ). "set the sort position to 1
    * Sort rows by seatsocc descending
      DATA: lr_field TYPE REF TO cl_salv_wd_field.
      DATA: lr_rule3 TYPE REF TO CL_SALV_WD_SORT_RULE.
      lr_field = lv_value->if_salv_wd_field_settings~get_field( 'SEATSOCC' ).
      lr_field->if_salv_wd_sort~create_sort_rule( EXPORTING sort_order = if_salv_wd_c_sort=>sort_order_descending
      RECEIVING value = lr_rule3 ).
      lr_rule3->set_sort_position( 3 ). "set the sort position to 3
    In the above code, the sequence of sorting would be seatsmax price seatsocc
    If you dont specify the sort position, then the sequence of sorting would be the order in which the sort rules are created.
    In the above example, if we didnt set sort positions for the fields, then order would be price seatsmax seatsocc.
    Refer to this link for more info: https://cw.sdn.sap.com/cw/docs/DOC-33859
    Hope this helps!
    Regards,
    Srilatha

  • Full text query across multiple columns

    In the SQL Server, when you do the full text query, you can specify multiple columns, e.g.
    FREETEXT ( { column_name | [b](column_list) | * } , 'freetext_string' [ , LANGUAGE language_term ] )
    CONTAINS ( { column_name | [b](column_list) | * } , '< contains_search_condition>' [ , LANGUAGE language_term ])
    Where,
    column_list Indicates that several columns, separated by a comma, can be specified...
    * Specifies that all columns in the table registered for full-text searching should be used to search for the given contains search condition. The columns in the CONTAINS clause must come from a single table...
    That makes full text query cross multiple columns very convenient. Are there any mechnisms in Oracle to do the same thing?
    Thanks in advance.

    Thanks for your reply.
    I knew that you could build full text index for the multiple columns using Oracle Text. But that does not solve my problem, which is how to build the query to search multiple columns at once. Say, I have columns firstname, lastname, address, and email in the table customers. I want to get the results that ANY column contains 'bob'. In SQL Server, I can do
    select * from customers where contains(*, 'bob')
    that is. But for Oracle, I have to do
    select * from customers where contains('firstname', 'bob') or contains('lastname', 'bob') or contains('address', 'bob') or contains('email', 'bob')
    Can you imagine if I have many columns in many tables and I have to do the query against all columns in all tables? I have to dynamically get all the columns and then build the query string.
    So, any better solutions?

  • Error while posting Customer with Multiple sales areas using DEBMAS05.

    Dear experts,
    We are generating IDOCS vis SAP DS for posting Customer master. The message type used is DEBMAS and basic type is DEBMAS05.  we have a requirement to create 1 customer with multiple sales areas. However, we are ending up with a strange error:  "Fill all required fields SAPMF02D 0111 ADDR1_DATA-NAME1". Despite the IDOC going into status 51, the customer gets created and the 1st sales area too. the 2nd sales area however is not created!  The IDOC data definitely contains Name1, otherwise the customer would not have been created in the first place.
    As the error message is related to the Address data, I also explored upon exploring this erorr further on the lines of Central Address management where in the ADRMAS and DEBMAS have to be passed together(IDOC Serialiization).  OSS Note (384462)  provides further details about this. One Important point from the note is: 
    "As you have to specify the logical name of the sending system among other things, SAP is not able to make any default settings in the standard systems. When you use the serialization groups delivered as a standard by SAP, the address objects are imported before the master objects.Thus the sequence address data before master objects must only be adhered to if one of the following points applies to your application:
    Such fields are set as required entry fields that are only provided by the BAS in the Customizing of the customer or vendor master.
    For your customers, contact persons exist to which a private address or a different business address is assigned.".
    This is not the case in our situation, as we do not have required entry fields in customizing that are only provided by the BAS, so the error is all the more confusing and I am not too sure what the cause is.
    If someone have experienced the same issue before and have found a solution to it, kindly help out.

    I have found the cause and solution to this problem.
    This error ”Fill all required fields SAPMF02D 0111 ADDR1_DATA-NAME1” and other similar errors like “Fill all required fields SAPMF02D 0111 ADDR1_DATA-SORT1“ which occurrs during the IDOC posting when there are more than one sales area or company code occurs when the customer number range is set up for Internal numbering. This means, that the number gets generated only at the time of save and upon debugging the IDOC, we found out that after creating the customer and the first sales area/company code record, the segment E1KNA1M is cleared completely! This is the reason, it throws an error which points to a mandatory KNA1 field as missing. (Like NAME1, SORT1 etc.)
    This was resolved by splitting the IDOC into 2.
    The solution is to First post only the KNA1 segment and create the customer.
    In the second step, pass the IDOC with all other segments along with E1KNA1M, but pass only KUNNR in E1KNA1M and the rest of the fields in E1KNA1M as “/”:  you would have got the KUNNR after the first step.
    Important note: This requirement to split the IDOCs does not occur when the customer number is known upfront. (Meaning cases where the customer number is externally generated) I also tested this and created a customer with external numbering and I was able to post more than 1 sales area with the same IDOC. 
    I noticed multiple threads with the same issue, but none of it had a concrete answer. I hope this information will be useful for anyone facing similar problems.
    Cheers
    Venkat

  • Comparison of multiple column values with a single column value

    I have two separate tables say Tab1 and Tab2
    I want to select some datas , which is common to both the tables.
    In tab1 , there is a column 'STATE' and it's value is 'A'
    In tab2, there are multiple columns for the state, say STATE_A,STATE_B, STATE_C ETC and a row is present with the following details
    STATE_A = 1, STATE_B =1 ,STATE_C =0,STATE_D=1
    I need to select STATE when STATE_A ='1',
    if my STATE='B', this STATE has to be selected since STATE_B =' 1', similraly
    if my STATE='D', this STATE has to be selected since STATE_D =' 1',
    If my STATE='C', STATE_C should not get selected since it's '0'.
    Is it possible to do this in a single SELECT statement, where I have some other checks also or else how can I achieve it?

    Maybe this will help
    Select * from STATE_MAS ;
    STATE
    A
    B
    D
    F
    H
    Select * from STATE_CHILD
      STATE_A   STATE_B   STATE_C   STATE_D   STATE_E   STATE_F   STATE_G   STATE_H   STATE_I   STATE_J
            1         0         0         1         1         0         0         0         0         0
    CREATE OR REPLACE FUNCTION GET_STATE (P_VAL VARCHAR) RETURN NUMBER IS
    V_SQL VARCHAR2(200);
    V_COL VARCHAR2(35);
    P_RETURN NUMBER ;
    BEGIN
    V_COL := 'STATE_'||P_VAL;
    V_SQL := 'SELECT 1 FROM STATE_CHILD WHERE '||V_COL||' = 1 ';
    EXECUTE IMMEDIATE  V_SQL INTO P_RETURN ;
    RETURN P_RETURN ;
    END;
    SELECT STATE FROM STATE_MAS
    WHERE GET_STATE(STATE) = 1 ;
    STATE
    A
    D

Maybe you are looking for

  • I cant open my icloud its says connections error how can ı do connect?

    please help my father take my ipad and ı have an important email and ı thing go to www.icloud.com and ı write an apple ID and Paswor but connections error when icloud page can be opened ? THANKYOU FOR ALL ABAUT THİS

  • DELETING THE MASTER RECORDS

    Hi gurus, i want to upload the new master records into my system regarding the MM. first thing i want to delete the old records in the system and freshly want to load into the system. please give me the soluion how to do it. it is a development serve

  • HP UPD 5.3 - some clients print garbage

    Server: Windows 2008 R2 SP1. Clients: XP SP3. Yesterday I upgraded from HP UPD PS 5.2.6.9321 to 5.3.1.10527.  This morning I find out that tons of users are now printing "garbage".  This garbage is actually raw PostScript code from all types of appli

  • Cannot seem to upgrade ipad ios 3.2 to 4.3

    Backup function takes days and nothing seems to happen. Should I reset to factory?

  • What will take the place of protectlink on rv220w?

                       Aftert the end of life on Trend Micro Protectlink what is the game plan? Partner using his on rv220w routers..