Please Solve The SQL Query

Please Slove the Query as below:
          T1
|     A1     |     A2     |
|     TRUE     |     FALSE     |
|     FALSE     |     TRUE     |
|     TRUE     |     TRUE     |
|     FALSE     |     TRUE     |
Table Name is: T1 and it is having 2 columns A1 and A2.
Question is:
Using a simple SQL query try to get the total number of "TRUE" in the Table T1. Don't use any PL/SQL command,
just use simple SQL command.
Please write the full query.
Manojit.

select (Nvl(a.cnt_a1,0) + Nvl(b.cnt_a2,0)
from (select count(1) CNT_A1 from t1 where a1 = 'TRUE') A
(select count(1) CNT_A2 from t1 where as = 'TRUE') B
Please Slove the Query as below:
          T1
|     A1     |     A2     |
|     TRUE     |     FALSE     |
|     FALSE     |     TRUE     |
|     TRUE     |     TRUE     |
|     FALSE     |     TRUE     |
Table Name is: T1 and it is having 2 columns A1 and A2.
Question is:
Using a simple SQL query try to get the total number of "TRUE" in the Table T1. Don't use any PL/SQL command,
just use simple SQL command.
Please write the full query.
Manojit.

Similar Messages

  • Please provide the sql query on mentioned requirement in attached image.

    Please provide query for this requirement
    1.This is my main table  data.
    FACTID DATE_DMN_KEY
    WQTY ROWID
    AVG_7_AMT
    1 100   
    1000 1
    NULL
    1 200 2000
    2 NULL
    1 300 3000
    3 NULL
    1 400 4000
    4 NULL
    1 500 5000
    5 NULL
    1 600 6000
    6 NULL
    1 700 7000
    7 NULL
    1 800 8000
    8 NULL
    1 900 9000
    9 NULL
    1 1000
    10000 10
    NULL
    2.  column rowid =10 is the latest record and COLUMN AVG_7_AMT value should be update as below
        Sum (WQTY=10000+9000+8000+7000+6000+5000+4000)/7
    3.FOR  column rowid =9 record and COLUMN AVG_7_AMT value should be update as below
       Sum (WQTY=9000+8000+7000+6000+5000+4000+3000)/7
    4. FOR  column rowid =8 record and COLUMN AVG_7_AMT value should be update as below
       Sum (WQTY=8000+7000+6000+5000+4000+3000+2000)/7
    5. . FOR  column rowid =7 record and COLUMN AVG_7_AMT value should be update as below
       Sum (WQTY=7000+6000+5000+4000+3000+2000+1000)/7
    6.  FOR  column rowid =6 record and COLUMN AVG_7_AMT value should be update as below
       Sum (WQTY=6000+5000+4000+3000+2000+1000)/6
    7. FOR  column rowid =5 record and COLUMN AVG_7_AMT value should be update as below
       Sum (WQTY=5000+4000+3000+2000+1000)/5
    How we can write sql  query for this type of requirement.

    Query is working but partially..
    if you insert  below records in same fact table then it wont work because factId=1 and factid 2 are different transaction .. how 
    Insert into fact Values
    (2, 100, 1000,   NULL),
    (2, 200, 2000,  NULL),
    (2, 300, 3000,  NULL),
    (2 ,400, 4000,  NULL),
    (2, 500 ,5000,  NULL),
    (2, 600, 6000,  NULL),
    (2, 700, 7000 , NULL),
    (2, 800, 8000,  NULL),
    (2, 900, 9000,  NULL),
    (2, 1000,  10000,   NULL )
    then result should like below.
    FACTID
    DATE_DMN_KEY
    WQTY
    ROWID
    AVG_7_AMT
    1
    100
    1000
    1
    1000
    1
    200
    2000
    2
    3000
    1
    300
    3000
    3
    6000
    1
    400
    4000
    4
    10000
    1
    500
    5000
    5
    15000
    1
    600
    6000
    6
    21000
    1
    700
    7000
    7
    28000
    1
    800
    8000
    8
    35000
    1
    900
    9000
    9
    42000
    1
    1000
    10000
    10
    49000
    2
    100
    1000
    1
    1000
    2
    200
    2000
    2
    3000
    2
    300
    3000
    3
    6000
    2
    400
    4000
    4
    10000
    2
    500
    5000
    5
    15000
    2
    600
    6000
    6
    21000
    2
    700
    7000
    7
    28000
    2
    800
    8000
    8
    35000
    2
    900
    9000
    9
    42000
    2
    1000
    10000
    10
    49000

  • Please suggest the sql query

    I have a column and the value in it is 123456789
    i want to get the output in horizontal way as 1,2,3,4,5,6,7,8,9

    Hi,
    Try this please
    SELECT REGEXP_REPLACE('123456789' ,'(.)', '\1,') AS REPT from DUAL

  • Find out the sql query for special characters.

    Hi,
    I have the emp table with column name first_name.In that table i have lot records with first_name inlcudes the below mentioned special characters.
    ¡ , ¿, ,Ä,Å,ä,ª,À,Á,Ã,à,á,ã,å,Æ,æ,Ç,ç,È,É,Ê,Ë,è,é,ê,ë,Ì,Í,Î, Ï,ì,í,î,ï, Ñ,ñ, ô, º, Ò, Ó, Ô, Õ, Ö, Ø, ò, ó, õ, ö, ø, ß, Û, Ù, Ú, Ü,ù, ú, û, ü, ÿ,
    I am looking for the records with includes the above mentioned special characters in the first_name column.
    Can u please give the sql query to find out the records.
    Thanks&Regards
    N.Sivaraman

    I am looking for the records with includes the above mentioned special characters in the first_name column.One way would be:
    select emp.*
      from emp,
           table (
             sys.odcivarchar2list ('¡',
                                   'Ä',
                                   'Å',
                                   'ä',
                                   'ª',
                                   'À',
                                   'Á',
                                   'Ã',
                                   'à',
                                   'á',
                                   'ã',
                                   'å',
                                   'Æ',
                                   'æ',
                                   'Ç',
                                   'ç',
                                   'È',
                                   'É',
                                   'Ê',
                                   'Ë',
                                   'è',
                                   'é',
                                   'ê',
                                   'ë',
                                   'Ì',
                                   'Í',
                                   'Î',
                                   'Ï',
                                   'ì',
                                   'í',
                                   'î',
                                   'ï',
                                   'Ñ',
                                   'ñ',
                                   'ô',
                                   'º',
                                   'Ò',
                                   'Ó',
                                   'Ô',
                                   'Õ',
                                   'Ö',
                                   'Ø',
                                   'ò',
                                   'ó',
                                   'õ',
                                   'ö',
                                   'ø',
                                   'ß',
                                   'Û',
                                   'Ù',
                                   'Ú',
                                   'Ü',
                                   'ù',
                                   'ú',
                                   'û',
                                   'ü',
                                   'ÿ'
    where instr (ename, column_value) > 0

  • How to view the sql query?

    hi,
      how to view the sql query formed from the xml structure in the receiver jdbc?

    You can view SAP Note at
    http://service.sap.com/notes
    But you require SMP login ID for this which you should get from your company. The content of the notes are as follows:
    Reason and Prerequisites
    You are looking for additional parameter settings. There are two possible reasons why a feature is available via the "additional parameters" table in the "advanced mode" section of the configuration, but not as documented parameter in the configuration UI itself:
    Category 1: The parameter has been introduced for a patch or a SP upgrade where no UI upgrade and/or documentation upgrade was possible. In this case, the parameter will be moved to the UI and the documentation as soon as possible. The parameter in the "additional parameters" table will be deprecated after this move, but still be working. The parameter belongs to the supported adapter functionality and can be used in all, also productive, scenarios.
    Category 2. The parameter has been introduced for testing purposes, proof-of-concept scenarios, as workaround or as pre-released functionality. In this case, the parameter may or may not be moved to the UI and documentation, and the functionality may be changed, replaced or removed. For this parameter category there is no guaranteed support and usage in productive scenarios is not supported.
    When you want to use a parameter documented here, please be aware to which category it belongs!
    Solution
    The following list shows all available parameters of category 1 or 2. Please note:
    Parameter names are always case-sensitive! Parameter values may be case-sensitive, this is documented for each parameter.
    Parameter names and values as documented below must be used always without quotaton marks ("), if not explicitly stated otherwise.
    The default value of a parameter is always chosen that it does not change the standard functionality
    JDBC Receiver Adapter Parameters
    1. Parameter name: "logSQLStatement"
                  Parameter type: boolean
                  Parameter value: true for any string value, false only for empty string
                  Parameter value default: false (empty String)
                  Available with: SP9
                  Category: 2
                  Description:
                  When implementing a scenario with the JDBC receiver adapter, it may be helpful to see which SQL statement is generated by the JDBC adapter from the XI message content for error analysis. Before SP9, this can only be found in the trace of the JDBC adapter if trace level DEBUG is activated. With SP9, the generated SQL statement will be shown in the details page (audit protocol) of the message monitor for each message directly.
                  This should be used only during the test phase and not in productive scenarios.
    Regards,
    Prateek

  • The SQL query is not executing

    Hi
    I have the following situation: In a project we designed our reports calling a stored procedure the exits in a MS SQL Server 200 database. The Stored Procedures works fine and when they are used in the report everything works perfectly.
    The reports are being made with CR DEsigner 11, when the designer ends them, ha pass them to me and we put them in our java web application. I open them and even preview them since the Crystal Reprots Perspective of Eclipse and I can see the data, so everything to this point is OK.
    The problem comes when I change of connection, I'm trying to connect every report to the same host and database, and when the reprot is displayed in the browser there is no data. I profile the SQL commands that are executed when the report is requested and I found that the reprot is not executing the stored procedure.
    I guess because i'm connectring the report to the same database and host that was used when the report is created and i'm also passing exactly the same parameters of the stored procedure, then report thinks that it doesn't have executing again becuase it will be the same information.
    SO, i wonder if there is a way to request to the report to execute the sql query every time i have to display it.
    thanks for any help.

    What happens when you try to view the report using a simple viewer.jsp?without changing the connection?
    2009-05-25 14:06:09,250 ERROR com.businessobjects.reports.sdk.JRCCommunicationAdapter -  detected an exception: Error de conexión: [SQLServer 2000 Driver for JDBC]Error establishing socket.
    But the database server is ok, so i think the rpt needs more information to be connect to the database.
    Also what happens if you dont use the data bean and give everything there only?
    The same, the rpt is not executing the stored procedure.
    Did anything change on the RDBMS side? Additional packages, changes to the schema, ownership, etc?
    No, the server is ok and the database is ok.
    If you configure Log4J logging to DEBUG, you should see the database invokes from the Crystal Java engine, specifically the queries sent and the number of rowsets returned. Do you notice any errors?
    I have a problem here with log4j. In my project i'm using spring and with the help of spring i configure log4j, basically with spring is easier to configure log4j.
    I'm telling you this because i have log4j working but when my application reaches the code to change the connection to the rerport, log4j dies and stop sending any message to the stdout or to a log file. I haven't since this behavior in any other app o library. So i want to guess i have something wrong with my log4j or maybe with log4j+spring.
    So, i remove all the code of spring referring to log4j, but the problem with log4j wasn't solved.
    What i will try now is to remove spring from the project.
    This is my log4j.properties:
    log4j.rootLogger=DEBUG, stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n

  • Give me the sql query which calculte the table size in oracle 10g ecc 6.0

    Hi expert,
    Please  give me the sql query which calculte the table size in oracle 10g ecc 6.0.
    Regards

    Orkun Gedik wrote:
    select segment_name, sum(bytes)/(1024*1024) from dba_segments where segment_name = '<TABLE_NAME>' group by segment_name;
    Hi,
    This delivers possibly wrong data in MCOD installations.
    Depending on Oracle Version and Patchlevel dba_segments does not always have the correct data,
    at any time esp. for indexes right after being rebuild parallel (Even in DB02 because it is using USER_SEGMENTS).
    Takes a day to get the data back in line (never found out, who did the correction at night, could be RSCOLL00 ?).
    Use above statement with "OWNER = " in WHERE for MCOD or connect as schema owner and use USER_SEGMENTS.
    Use with
    segment_name LIKE '<TABLE_NAME>%'
    if you like to see the related indexes as well.
    For partitioned objects, a join from dba_tables / dba_indexes to dba_tab_partitions/dba_ind_partitions to dba_segments
    might be needed, esp. for hash partitioned tables, depending on how they have been created ( partition names SYS_xxxx).
    Volker

  • How does Index fragmentation and statistics affect the sql query performance

    Hi,
    How does Index fragmentation and statistics affect the sql query performance
    Thanks
    Shashikala
    Shashikala

    How does Index fragmentation and statistics affect the sql query performance
    Very simple answer, outdated statistics will lead optimizer to create bad plans which in turn will require more resources and this will impact performance. If index is fragmented ( mainly clustered index,holds true for Non clustred as well) time spent in finding
    the value will be more as query would have to search fragmented index to look for data, additional spaces will increase search time.
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers
    My TechNet Wiki Articles

  • Variable to hold the number of records returned by the SQL Query.

    Hi folks,
    Is there any way to hold the number of records that could be returned by the SQL query we use to make a report?
    If so, please do come up with the answer.
    Cheers,
    PCZ.

    Hi there,
    Well, there is no actual business requirement.
    It is just the curiosity of mine.
    I would like to handle
    1) the number of records our report query returns or
    2) the query itself
    to write a better pl/sql code in any trigger/program unit, if any business logic beckons in future.
    Cheers,
    PCZ.

  • PLEASE SEND ME SQL query to list ALL CONSTRAINTS ON EMPLOYEES TABLE FROM OU

    PLEASE SEND ME SQL query to list ALL CONSTRAINTS ON EMPLOYEES TABLE FROM OUTSIDE PP SCHEMA INCLUDING SCHEMA NAME AND CONSTraint NAME
    Username : PP
    Table : Employees

    I think you are looking for below query :
    SQL> SHOW USER;
    USER is "SCOTT"
    SQL> select owner,constraint_name,constraint_type,table_name,r_owner,r_constraint_name
      2    from all_constraints
      3    where constraint_type='R'
      4   and r_constraint_name in (select constraint_name from all_constraints
      5    where constraint_type in ('P','U') and table_name='EMP');
    OWNER                          CONSTRAINT_NAME                C TABLE_NAME                     R_OWNER                        R_CONSTRAINT_NAME
    TEST1                          ERL_EMP_FK_1                   R EMPLOYEE                       SCOTT                          PK_EMP
    1 row selected.Means, TEST1 user is having a constraint ERL_EMP_FK_1 on his table EMPLOYEE. Which is using PK_EMP (primary key of SCOTT user's 'EMP' [in the query])
    Regards
    Girish Sharma

  • Overflow the SQL query string buffer

    Hello,
    I have a report that is using a query to determine values for a parameter. In Report Builder everything renders fine, but when I publish the report on the Report Server, it will not render if too many values are entered for the parameter, including "Select
    All". The reason for this behavior is likely due to the number of possible values for the parameter being over 2500. My research has shown that this is causing an overflow of the SQL query string buffer. The obvious fix is to not use that column as a
    parameter, but the power that be are insisting. My system administrator says he can likely increase the buffer size, but has asked me to find out how and where to do that. Any help would be much appreciated.

    Hi CrazyAlligator,
    According to your description, you have more than 2500 values within a parameter. It throws overflow exception when selecting all values. Right?
    Microsoft security update MS11-100 limits the maximum number of form keys, files, and JSON members to
    1000 in an HTTP request. Because of this change, ASP.NET applications reject requests that have more than
    1000 of these elements. HTTP clients that make these kinds of requests will be denied, and an error message will appear in the web browser. The error message will usually have an HTTP 500 status code. This new limit can be configured on a per-application
    basis. Please see the "Resolution" section for configuration instructions. Please refer the KB article:
    https://support2.microsoft.com/kb/2661403?wa=wsignin1.0
    In this scenario, we need add the setting in the web.config file. Please follow the steps below:
    Go to the reporting services installation folder.
    Go to the report server folder and make a backup of the file “Web.config”. Once you have the backup, open the original file in notepad and add the following entry under the Configuration section:
        <appSettings>
                    <add key="aspnet:MaxHttpCollectionKeys" value="10000"/>
        </appSettings>
    Go to the Report Manager folder and again make a backup of the file “Web.config”. Once you have the backup, open the original file in notepad and add the following entry under the appSettings tag:
    <add key="aspnet:MaxHttpCollectionKeys" value="10000"/
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • How to get cm:search to use the max attribute when creating the SQL query?

    When we use the max attribute in the cm:search tag, it does not seem to honor the max attribute when creating the SQL query. However, the result returned from the tag is limited to the number specified by the max attribute. Then the tag seems to work as intended, but the performance will be sub optimal when the SQL query returns unnecessary rows to the application.
    We use the cm:search tag to list the latest news (ordered by date), and with the current implementation we have to expect a decrease in performance over time as more news is published. But we can’t live with that. We need to do the constraint in the SQL query, not in the application.
    The sortBy attribute of cm:search is translated to “order by” in the SQL query, as expected.
    Is it possible to get cm:search to generate the SQL query with an addition of “where rownum <= maxRows”?

    Hi Erik,
    The behavior of a repository in regards to the search tag's max results parameter is dependent on the underlying repository's implementation. That said, the OOTB repository in WLP does augment the generated SQL to limit the number of rows returned from the database. This is done in the parsing logic. This behavior may differ with other repository implementations.
    -Ryan

  • How to find out which Tables have been accessed without looking at the SQL query ?

    Hi,
    I would like to know is there a way to find out what queries have been executed and on which tables without looking at the SQL query.
    I have an old C++ code which calls some library functions to access the Oracle database. The source code for the library is not available to me yet. The functions selects/updates/deletes and inserts based on some input parameters I give. I do not know which tables it affects. How do I find out the actual SQL query and/or the tables it accesses ? I was told about V$SQL table that
    has the most recently executed queries, but
    I did'nt see any queries connected to my process.
    Could anybody help me on this ?
    Thanks
    Jagdeep
    [email protected]
    null

    PRECISE/SQL can help you if you have access to it
    2nd option can be that turn on SQL_TRACE
    Run executable of ur c++ program
    it will create a trace file in user_dump_dest
    and then using TKPROF u can see all quesries and their plan also.
    HTH
    Gagan Deep Singh
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by (jagdeeps):
    Hi,
    I would like to know is there a way to find out what queries have been executed and on which tables without looking at the SQL query.
    I have an old C++ code which calls some library functions to access the Oracle database. The source code for the library is not available to me yet. The functions selects/updates/deletes and inserts based on some input parameters I give. I do not know which tables it affects. How do I find out the actual SQL query and/or the tables it accesses ? I was told about V$SQL table that
    has the most recently executed queries, but
    I did'nt see any queries connected to my process.
    Could anybody help me on this ?
    Thanks
    Jagdeep
    [email protected]<HR></BLOCKQUOTE>
    null

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • How to display the out put of the sql query in a text file using forms

    I want to display the out put of the sql query in a text file using forms 6.0.Same could be done using spool command in sqlplus but i want it using forms....Fiaz

    Have a look at the text_io package:
    http://www.oracle.com/webapps/online-help/forms/10g/state?navSetId=_&navId=3&vtTopicFile=f1_help/oraini/c_text_io.html&vtTopicId=
    cheers

Maybe you are looking for

  • How to pass a "Button" reference in one swf to anthor swf file?

    Dear all: Please let me describe my problem first. In my application, there are two swf files:"sender.swf" and "receiver.swf" A button named "re_Button" is in "receive.swf", and now i wanna operate the "re_Button" through the "sender.swf". How to do

  • Adobe Premiere 13 stops working on Hp Pavilion AMD Windows 8

    I have installed adobe premiere 13 on my new windows 8 computer. It is a hp pavilion with AMD A4-5000 APU with Radeon (TM) HD graphics 1.50 GHz and 6 GB of RAM and a 64 bit operating system. My problem is that every time I try to edit a video, a mess

  • Dynamic Tree Creation using JSP, Struts framework

    I urgently require tips/information/code snippet for creating a Dynamic Tree structure. Tree is the hierarchical folder structure that we see in windows operating system. Dynamic tree in the sense that all nodes shall be populated from database & a r

  • How can I get return to 10.6? Uninstall yosemite

    How can I get return to 10.6? Uninstall yosemite

  • Issue : Metrics getting multiplied

    Hi All, I am working on the contracts data model where my dimension is at the header level and fact is a the subline level. There is one to many relationship between header and subline. One header can have many sublines. The issue is that i need to s