Please solve the query

Hi,
I have a query which requires me to find the language that is known by only on programmer
PNAME PROF1 PROF2
anand pascal basic
altaf clipper cobol
juliana cobol dbase
kamala c dbase
mary c++ oracle
nelson cobol dbase
partick pascal clipper
qadir assembly c
ramesh pascal dbase
resecca basic cobol
remitha c assembly
revathi pascal basic
vijaya foxpro c
The answer to this query is
C++
foxpro
oracle.

Hi APC,
SQL> SELECT prof, p_cnt FROM(
  2  SELECT prof1 AS prof, count(pname) AS p_cnt
  3  FROM user_lang
  4  GROUP BY prof1
  5  UNION
  6  SELECT prof2 , count(pname)
  7  FROM user_lang
  8  GROUP BY prof2 )
  9  WHERE p_cnt = 1;
PROF                      P_CNT
assembly                      1
basic                         1
c++                           1
clipper                       1
foxpro                        1
oracle                        1
6 rows selected.You have to count AFTER the union... ;-)
Regards,
Gerd

Similar Messages

  • Please solve the query in a single query

    1. display names of scott's collegue who earn more than scott
    using the emp table of scott schema

    As it's homework, we could always post you a really poor example of code like this:
    SQL> ed
    Wrote file afiedt.buf
      1  select *
      2  from emp
      3  where (1,empno) in (
      4                    select case when sal > (select sal from emp where ename = 'SCOTT') then 1 else 0 end as flag, empno
      5                    from emp
      6*                  )
    SQL> /
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7839 KING       PRESIDENT            17/11/1981 00:00:00       5000                    10But it would be better if you gave us an example of what you have done yourself, before we show you where you have gone wrong and how it can be improved.

  • 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.

  • The query processor ran out of stack space during query optimization. Please simplify the query

    Can you suggest me that what should i do in this case.
    Actually i am having one table that is a MasterTable.I am referring this table in more than 300 tables that means i am having foreign key of this primary key in 300+ tables.
    due to this i am getting following error during deleting any row,
    doesn't matter that data is existing in reference table or not.
    Error that i am getting is 
    "The query processor ran out of stack space during query optimization. Please simplify the query"
    Can you suggest me that what should i do to avoid this error,because i am unable to delete this entry.
    Apart from it,i am getting performance problem too,so is it due to such huge FK on it.
    Please suggest me on following points
    1. Is it worst way to handle it,if yes then please suggest me solution for it.
    2. If it is a correct way then what should i do if getting error during deleting any record.
    3. Is it right to create Foreign key on each table where i am saving data of this master. if no then how to manage integrity.
    4. What people do in huge database when they wants to create foreign key for any primary key.
    5. Can you suggest me that how DBA's are handling this in big database,where they are having huge no. of tables.

    The most common reason of getting such error is having more than 253 foreign key constraints on a table. 
    The max limit is documented here:
    http://msdn.microsoft.com/en-us/library/ms143432(SQL.90).aspx 
    Although a table can contain an unlimited number of FOREIGN KEY constraints, the recommended maximum is 253. Depending on the hardware configuration hosting SQL Server, specifying additional foreign key constraints may be expensive for the query
    optimizer to process. If you are on 32 bit, then you might want to move to 64 bit to get little bigger stack space but eventually having 300 FK is not something which would work in long run.
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • I have a problem in the answers to the questions on my account I can not buy anything, please solve the problem, I have a problem in the answers to the questions on my account I can not buy anything, please solve the problem

    I have a problem in the answers to the questions on my account I can not buy anything, please solve the problem

    You are not addressing Apple here. And your post is a bit confusing. See Klaus's answer in this thread:
    https://discussions.apple.com/thread/5228474?tstart=0

  • I bought iphone 4 in US and i and other person not able to listen properly because on the time of conversation voice cracking and difficult to understand each others.so i would like to request you that please solve the above problem.i love my iphone.

    Sir,
    I bought iphone 4 in US.last 6 month me and other person not able to listen properly the voice because the voice is cracking.i have called earlier about the above problem and they said to upload the new verson 6.1.3 and it will be done but after loading this version still i am facing the same problem.so ,i would like to request you that please solve the above problem as soon as you can.I will be thankful to you.i love my apple Iphone.
    waiting for your earliest reply.
    thanks
    Rajeev Gupta

    Hello sir
    As you know about my iPhone 4 which has a problem of voice cracking so I would like to replace to other phone like IPhone 5s.I will pay the replacement charges immediately.i am reaching miami on 19th of janvary 2014 so I would like to request you please arrange my appointment on the Apple store,dadeland mall ,miami at 15.00pm as I will reach miami at 13.00pm and my flight to India at 19.00pm.
    Last time you told to replace at miami on 26th of September but without oppoimtment they have not entertained me.so I would like to request you that please arrange my appointment this time
    I will be thankful to you
    Rajeev Gupta

  • My AppStore can not download app. He said need to fill in credit card. But I got no credit card. And how I fill in? Please solve the problem. Thank you.

    My AppStore can not download app. He said need to fill in credit card. But I got no credit card. And how I fill in? Please solve the problem. Thank you.
    <Email Edited by Host>

    Hi Steve,
    If you don't have a credit card for the billing information you may be able to use a gift card or another form of payment.
    Please check out this article for details.
    Why can’t I select None when I edit my Apple ID payment information? - Apple Support
    Best,
    Nubz

  • Please give the query to find out primary key in table in Sql plus

    Dear friends,
    Please give me the query to find out the primary key in Sql plus.

    hi
    SQL> DESC user_constraints
    Name                                                                                                  
    OWNER                                                                                                 
    CONSTRAINT_NAME                                                                                       
    CONSTRAINT_TYPE                                                                                       
    TABLE_NAME                                                                                            
    SEARCH_CONDITION                                                                                      
    R_OWNER                                                                                               
    R_CONSTRAINT_NAME                                                                                     
    DELETE_RULE                                                                                           
    STATUS                                                                                                
    DEFERRABLE                                                                                            
    DEFERRED                                                                                              
    VALIDATED                                                                                             
    GENERATED                                                                                             
    BAD                                                                                                   
    RELY                                                                                                  
    LAST_CHANGE                                                                                           
    INDEX_OWNER                                                                                           
    INDEX_NAME                                                                                            
    INVALID                                                                                               
    VIEW_RELATED                                                                                          
    SQL> SELECT constraint_name,table_name,r_constraint_name,status
      2  FROM user_constraints WHERE constraint_type='P';
    CONSTRAINT_NAME                TABLE_NAME                     R_CONSTRAINT_NAME              STATUS
    SYS_C003141                    CUSTOMERS                                                     ENABLED
    PK_DEPT                        DEPT                                                          ENABLED
    SYS_C003139                    SALESREPS                                                     ENABLEDKhurram

  • Please explain the query?

    hello all,
    please explain below query used in solution below, thanks in advance!
    ELECT MAX(P1.ET) AS ST, P2.ST AS ET
    FROM XYZ AS P1
    INNER JOIN XYZ AS P2 ON (P1.ST < P2.ST)
    GROUP BY P2.ST
    HAVING MAX(P1.ET) < P2.ST
    IF OBJECT_ID('XYZ') IS NOT NULL
    DROP TABLE XYZ
    GO
    CREATE TABLE XYZ
    id int identity(1,1),
    ST smalldatetime NOT NULL,
    ET smalldatetime NOT NULL
    GO
    INSERT INTO XYZ (ST, ET)
    VALUES ('2010-01-01 9:00AM', '2010-01-01 10:00AM')
    INSERT INTO XYZ (ST, ET)
    VALUES ('2010-01-01 9:00AM', '2010-01-01 12:00PM')
    INSERT INTO XYZ (ST, ET)
    VALUES ('2010-01-01 1:00PM', '2010-01-01 2:00PM')
    INSERT INTO XYZ (ST, ET)
    VALUES ('2010-01-01 3:00PM', '2010-01-01 5:00PM')
    INSERT INTO XYZ (ST, ET)
    VALUES ('2010-01-01 11:00AM', '2010-01-01 12:00PM')
    GO
    WITH Gaps(Gap) AS
    SELECT COALESCE(SUM(DATEDIFF(MINUTE,ST,ET)), 0)
    FROM (
    SELECT MAX(P1.ET) AS ST, P2.ST AS ET
    FROM XYZ AS P1
    INNER JOIN XYZ AS P2 ON (P1.ST < P2.ST)
    GROUP BY P2.ST
    HAVING MAX(P1.ET) < P2.ST
    ) gaps
    SELECT (
    COALESCE(DATEDIFF(MINUTE, MIN(ST), MAX(ET)), 0)
    - (SELECT Gap FROM Gaps)
    ) / 60.0 TotalHrs
    FROM XYZ

    SELECT MAX(P1.ET) AS ST, P2.ST AS ET
    FROM XYZ AS P1
    INNER JOIN XYZ AS P2 ON (P1.ST < P2.ST)
    GROUP BY P2.ST
    HAVING MAX(P1.ET) < P2.ST
    Finds all of the gaps (that is time that is not in any interval in your original data.  To see how it works, let's look at an example.  I'm going to use data that is a little different than your original data because your data has no gaps. 
    The query still works if you have no gaps, but it is easier to see what it is doing if the data has some gaps.  Also, I'm going to explicitly set the id column instead of making it an identity.  This will make it a little easier to identify each
    row in the following explanation. So the data I'm going to work with is
    CREATE TABLE XYZ
    id int,
    ST smalldatetime NOT NULL,
    ET smalldatetime NOT NULL
    GO
    INSERT INTO XYZ (id, ST, ET)
    VALUES (1, '2010-01-01 9:00AM', '2010-01-01 10:00AM')
    INSERT INTO XYZ (id, ST, ET)
    VALUES (2, '2010-01-01 9:00AM', '2010-01-01 12:00PM')
    INSERT INTO XYZ (id, ST, ET)
    VALUES (3, '2010-01-02 1:00PM', '2010-01-02 2:00PM')
    INSERT INTO XYZ (id, ST, ET)
    VALUES (4, '2010-01-03 3:00PM', '2010-01-03 5:00PM')
    INSERT INTO XYZ (id, ST, ET)
    VALUES (5, '2010-01-03 7:00PM', '2010-01-03 9:00PM')
    Notice that the gaps here are from row 2 to row 3 (12PM on the 1st to 1PM on the 2nd) and row 3 to row 4 (2PM on the 2nd to 3PM on the 3rd) and row 4 to row 5 (5PM on the 3rd to 7PM on the 3rd).  So that's what the above subquery should be finding for
    us.
    To see what a query you don't understand is doing, simplify it to the smallest part you can and see what it returns and then build it up to the final query.  So the simplest thing we can do is just the from clause.  That gives us
    SELECT *
    FROM XYZ AS P1
    INNER JOIN XYZ AS P2 ON (P1.ST < P2.ST)
    /* That gives us the result
    1 2010-01-01 09:00:00 2010-01-01 10:00:00 3 2010-01-02 13:00:00 2010-01-02 14:00:00
    2 2010-01-01 09:00:00 2010-01-01 12:00:00 3 2010-01-02 13:00:00 2010-01-02 14:00:00
    1 2010-01-01 09:00:00 2010-01-01 10:00:00 4 2010-01-03 15:00:00 2010-01-03 17:00:00
    2 2010-01-01 09:00:00 2010-01-01 12:00:00 4 2010-01-03 15:00:00 2010-01-03 17:00:00
    3 2010-01-02 13:00:00 2010-01-02 14:00:00 4 2010-01-03 15:00:00 2010-01-03 17:00:00
    1 2010-01-01 09:00:00 2010-01-01 10:00:00 5 2010-01-03 19:00:00 2010-01-03 21:00:00
    2 2010-01-01 09:00:00 2010-01-01 12:00:00 5 2010-01-03 19:00:00 2010-01-03 21:00:00
    3 2010-01-02 13:00:00 2010-01-02 14:00:00 5 2010-01-03 19:00:00 2010-01-03 21:00:00
    4 2010-01-03 15:00:00 2010-01-03 17:00:00 5 2010-01-03 19:00:00 2010-01-03 21:00:00
    Now we want to Group by P2.ST and get the MAX(P1.ET) and P2.ST, so that gives us
    SELECT MAX(P1.ET) AS ST, P2.ST AS ET
    FROM XYZ AS P1
    INNER JOIN XYZ AS P2 ON (P1.ST < P2.ST)
    GROUP BY P2.ST
    /* Result is
    2010-01-01 12:00:00 2010-01-02 13:00:00
    2010-01-02 14:00:00 2010-01-03 15:00:00
    2010-01-03 17:00:00 2010-01-03 19:00:00
    Now with this sample data there are no rows in the output with MAX(P1.ET) > P2.ST.  But if there was one, you would not want that row because it is not a real gap (obviously, a gap can't start today and end yesterday).  (If you want to see how
    you could get a case like that, add a row 6 to the sample data with a ST of 2010-01-01 7:00PM and an ET of 2010-01-03 9:00PM.)
    So we add a HAVING MAX(P1.ET) < P2.ST to remove those cases.
    That leaves us with all of the gaps.  So then with
    SELECT COALESCE(SUM(DATEDIFF(MINUTE,ST,ET)), 0)
    FROM (
    SELECT MAX(P1.ET) AS ST, P2.ST AS ET
    FROM XYZ AS P1
    INNER JOIN XYZ AS P2 ON (P1.ST < P2.ST)
    GROUP BY P2.ST
    HAVING MAX(P1.ET) < P2.ST
    ) gaps
    we get the total amount of time in all gaps.  Then the final result is just the time from the earliest ST to the latest ET minus the total time from the gap.
    Tom

  • Solve the query

    Hi all,
    We r working on SQL queries unable to solve teh below query.
    "Display the names of the highest paid programmers for each language"
    The table relating to the query is given below.
    PNAME DOB DOJ S PROF1 PROF2 SALARY
    anand 21-APR-66 21-APR-92 m pascal basic 3200
    altaf 02-JUL-64 13-NOV-90 m clipper cobol 2800
    juliana 31-JAN-68 21-APR-90 f cobol dbase 3000
    kamala 30-OCT-68 02-JAN-92 f c dbase 2900
    mary 24-JUN-70 01-FEB-91 f c++ oracle 4500
    nelson 11-SEP-65 11-OCT-89 m cobol dbase 2500
    partick 10-NOV-65 21-APR-90 m pascal clipper 2800
    qadir 31-AUG-65 21-APR-91 m assembly c 3000
    ramesh 03-MAY-67 28-FEB-91 m pascal dbase 3200
    resecca 01-JAN-67 28-DEC-90 m basic cobol 2500
    remitha 19-APR-70 20-APR-93 f c assembly 3600
    revathi 02-DEC-69 02-JAN-92 f pascal basic 3700
    vijaya 14-DEC-65 02-MAY-92 f foxpro c 3500
    Thanking in advance.
    Milind.

    you can achieve it using analytics.
    SQL> create table dummy(ename varchar2(32), salary number, language varchar2(32))
      2  /
    Table created.
    SQL>
    SQL> insert into dummy values('Scott', 5000, 'C')
      2  /
    1 row created.
    SQL> insert into dummy values('Tiger', 4000, 'C')
      2  /
    1 row created.
    SQL> insert into dummy values('Mark', 5000, 'Java')
      2  /
    1 row created.
    SQL> insert into dummy values('Smith', 4000, 'Java')
      2  /
    1 row created.
    SQL> insert into dummy values('White', 3000, 'Oracle')
      2  /
    1 row created.
    SQL> insert into dummy values('Blake', 25000, 'C++')
      2  /
    1 row created.
    SQL>
    SQL> set linesize 1000
    SQL> column ename format a32
    SQL> column salary format 9999999
    SQL> column language a32
    SP2-0158: unknown COLUMN option "a32"
    SQL>
    SQL> select * from (
      2  select ename, salary , language
      3       , row_number() over (partition by language order by salary desc ) high_sal
      4  from dummy)
      5  where high_sal=1
      6  /
    ENAME                              SALARY LANGUAGE                           HIGH_SAL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    Scott                                5000 C                                         1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    Blake                               25000 C++                                       1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    Mark                                 5000 Java                                      1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    White                                3000 Oracle                                    1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    SQL> select ename, salary, language from (
      2  select ename, salary , language
      3       , row_number() over (partition by language order by salary desc ) high_sal
      4  from dummy)
      5  where high_sal=1
      6  /
    ENAME                              SALARY LANGUAGE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    Scott                                5000 C                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    Blake                               25000 C++                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
    Mark                                 5000 Java                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    White                                3000 Oracle                                                                                                             

  • Please optimize the query

    Hi,
    I have a query that will select the same tables and using Subquery. The query is taking too much time as the table has more records. Can anyone help to modify the query which can take minimum time. Thanks in Advance.
    Below is the query
    SELECT
    SIK_ROLLE_ID,SIK_OBJEKT_ID,SIK_AFTALE_ID,SIK_AFTALE_TP,ROLLE_TP,KNID,EJENDOMS_ID,EJENDOMS_TP, VURD_BLB
    ,VURD_VAKD,VURD_DT,HAIRCUT,SIK_VAKD,SIK_FOER_BLB,HAIRCUT_BLB,FORANST_PRIO_BLB,RETTIGHEDER_BLB,SIK_EFTER_BLB
    ,OVERSKREVET_MK,OVERSKREVET_BLB,MAN_HAIRCUT_BLB,MAN_OBJ_E_HCUT_BLB,GLDER_FRA_DT, TRANSAKTIONS_TP,SIK_STATUS_TP
    FROM
    ETZ3EDW.dbo.EWWH_KS_OBJ_KND2_HV A
    WHERE
    A.SIK_AFTALE_TP = 20130 and A.TRANSAKTIONS_TP not in ('S')
    AND A.GLDER_FRA_DT = ( SELECT MAX(B.GLDER_FRA_DT)
    FROM ETZ3EDW.DBO.EWWH_KS_OBJ_KND2_HV B
    WHERE B.GLDER_FRA_DT <= '2014-01-08'
    AND A.SIK_OBJEKT_ID = B.SIK_OBJEKT_ID
    AND A.SIK_AFTALE_ID = B.SIK_AFTALE_ID)

    Can you show us a execution plan of the query?
    CREATE TABLE #tmp (col DATE)
    INSERT INTO #tmp
    SELECT MAX(B.GLDER_FRA_DT)
    FROM ETZ3EDW.DBO.EWWH_KS_OBJ_KND2_HV BJOIN ETZ3EDW.dbo.EWWH_KS_OBJ_KND2_HV AON A.SIK_OBJEKT_ID = B.SIK_OBJEKT_ID
    AND A.SIK_AFTALE_ID = B.SIK_AFTALE_ID
    WHERE B.GLDER_FRA_DT <= '2014-01-08'SELECT
    SIK_ROLLE_ID,SIK_OBJEKT_ID,SIK_AFTALE_ID,SIK_AFTALE_TP,ROLLE_TP,KNID,EJENDOMS_ID,EJENDOMS_TP, VURD_BLB
    ,VURD_VAKD,VURD_DT,HAIRCUT,SIK_VAKD,SIK_FOER_BLB,HAIRCUT_BLB,FORANST_PRIO_BLB,RETTIGHEDER_BLB,SIK_EFTER_BLB
    ,OVERSKREVET_MK,OVERSKREVET_BLB,MAN_HAIRCUT_BLB,MAN_OBJ_E_HCUT_BLB,GLDER_FRA_DT, TRANSAKTIONS_TP,SIK_STATUS_TP
    FROM
    ETZ3EDW.dbo.EWWH_KS_OBJ_KND2_HV A
    WHERE
    A.SIK_AFTALE_TP = 20130 and A.TRANSAKTIONS_TP not in ('S')
    AND A.GLDER_FRA_DT IN (SELECT col FROM #tmp)
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Please help me solve the query

    CREATE TABLE SPONSER_UPDATION
    MEMBER VARCHAR2(12),
    SPONSER VARCHAR2(10),
    POINT NUMBER(10)
    MEMBER     SPONSER     POINT
    a     AS     10
    b     a     10
    c     b     10
    d     c     10
    e     d     10
    f     e     10
    i want a query or trigger on updating a single row all the row corresponding to it also gets updated example if i update a row with member f then its sponser e should also be updated and if sponser is is updatd then its sponser d should also be updated and if d is updated its spnser c should also be updated untill the last one through a single query
    i have written the trigger
    CREATE OR REPLACE TRIGGER points_updation
    AFTER UPDATE
    ON sponser_updation
    FOR EACH ROW
    DECLARE
    v_username varchar2(10);
    BEGIN
    update sponser_updation
    set
    point=point+10
    where
    :new.member=:old.sponser;
    END;
    after updation of any row error message is comming
    ORA-04098: trigger 'INVENT.SPONSER_UPDATION1' is invalid and failed re-validation
    thanks & Regards,
    anuj kumar singh!

    You can not insert, delete or update into this trigger type.
    try this:
    CREATE OR REPLACE TRIGGER points_updation BEFORE UPDATE ON sponser_updation FOR EACH ROW
    BEGIN
    if :new.member = :old.sponser then
    :new.point:=:new.point+10;
    end if;
    END;

  • Please solve the code

    class Horseradish
    //insert code here
    protected HorseRadish(int x)
    System.out.println("bok choy");
    class Washabi extends HorseRadish{
    public static void main(String[] args)
    Wasabi w=new Wasabi();
    which two,inserted independently at line 2,will allow the code to compile and produce the output "bok choy"?(choose two)
    1. //just a comment
    2. protected HorseRadish(){}
    3.protected HorseRadish()
    {this(42);}
    4.protected HorseRadish() { new horseRadish(42);}
    which two are the right options and why??
    please answer

    because we want people to think for themselves rather
    than spoonfeed them everything.
    When you start spoonfeeding them, they'll never learn
    to think on their feet and will forever come here
    with every tiniest problem.Original:
    public class Spoon {
        public static Answer feed(Person me) {
            /* Implementation */
    }New:
    protected class Spoon {
        private static Answer feed(Person me) {
            /* Implementation */
    }Problem solved.

  • Please tune the query

    Hi folks..pls tune/rewrite my query
    SELECT
    bu_code,bu_type,cust_no ,cur_code,sales_date,receipt_no,till_no,card_no,invoice_total,amount_of_goods,(invoice_total - amount_of_goods) AS amount_of_non_goods,
    pay_in_advance AS amounts_of_advance_pay,amount_of_discounts, Error_flag
    FROM
    (select
                distinct  'STO' AS BU_TYPE,
    workinv.tot_cust_no AS  cust_no,
    workinv.comp_code as comp_code,
    workinv.cash_no as till_no,
    workinv.receipt_no  as receipt_no,
    workinv.sales_date as sales_date,
    workinv.cur_code as cur_code,
    invhead.acct_usr_no as card_no,
    invhead.inv_no as inv_no,
    invhead.sto_no as bu_code, (SELECT MAX (DECODE (e.sum_code, 'TOTAL', e.amount_incl))
                                              FROM invoice_sums_t e
                                              WHERE e.inv_no = invsums.inv_no
                                              AND e.comp_code = invsums.comp_code) AS invoice_total,
                                             (SELECT MAX (DECODE (e.sum_code, 'PIA', e.amount_incl))
                                               FROM invoice_sums_t e
                                               WHERE e.inv_no = invsums.inv_no
                                              AND e.comp_code = invsums.comp_code) AS pay_in_advance,
                                             (SELECT SUM(e.amount_incl)
                                              FROM invoice_sums_t e
                                              WHERE E.SUM_CODE LIKE 'GOODS0%'
                                              AND e.inv_no = invsums.inv_no
                                              AND e.comp_code = invsums.comp_code) AS amount_of_goods,
                                             (SELECT SUM(e.amount_incl)
                                              FROM invoice_sums_t e
                                             WHERE E.SUM_CODE LIKE 'DISCOUNT0%'
                                              AND e.inv_no = invsums.inv_no
                                              AND e.comp_code = invsums.comp_code) AS amount_of_discounts ,
                                      CASE workinv.error_flag WHEN 'H' THEN 'Y' ELSE 'N' END
                                      AS Error_flag,
                                      WORKINV.ERROR_FLAG AS invoice_on_hold
    FROM  work_invoice_info_t workinv,
              invoice_header_t invhead,
              invoice_sums_t invsums,
              i_invoice_info_t_log invlog,
              o_pam_document_header_log_t opdhlt
    WHERE  invhead.comp_code= workinv.comp_code
    AND TRIM(workinv.Tot_cust_no) =TRIM(invlog.tot_cust_no)
    AND TRIM (workinv.sto_no) = invhead.sto_no
    AND TRIM (workinv.sales_date) =TO_CHAR (invhead.sales_date, 'YYMMDD')
    AND TRIM (workinv.cash_no) =TO_NUMBER (TRIM (invhead.cash_no))
    AND TRIM (workinv.receipt_no) =TO_NUMBER (TRIM (invhead.receipt_no))
    AND invhead.comp_code = invsums.comp_code
    AND invhead.inv_no = invsums.inv_no
    AND TRIM(workinv.sto_no) = invlog.sto_no
    AND TRIM(workinv.receipt_no) = invlog.receipt_no
    AND TRIM(workinv.cash_no) = invlog.cash_no
    AND TRIM(workinv.sales_date) = invlog.sales_date)dear folks am debugging the code as step by step
    i have taken inline query and selecting 1 as column from joining the same tables used in the above query
    select
       1
    FROM  work_invoice_info_t workinv,
              invoice_header_t invhead,
              invoice_sums_t invsums,
              i_invoice_info_t_log invlog,
              o_pam_document_header_log_t opdhlt
    WHERE  invhead.comp_code= workinv.comp_code
    AND TRIM(workinv.Tot_cust_no) =TRIM(invlog.tot_cust_no) --*if iam firing only this much then output is coming --in 2sec*
    AND TRIM (workinv.sto_no) = invhead.sto_no -- if i add the below 2 cols then it is taking lot of time(half an hr)
    AND TRIM (workinv.sales_date) =TO_CHAR (invhead.sales_date, 'YYMMDD')Hence should i create indexes on both 'sto_no' and 'sales_date' cols ?
    please shed some light on this

    newbie wrote:
    ..so how can i tune please share ideasTuning is a vast area. Many people spend their entire working lives tuning other people's code. Those people make fine livings from their work. They couldn't do that if it was merely a matter of squinting at some shonky piece of SQL and saying, "Ah, that's the badger!" No, tuning requires a great deal of context and additional information. Explain plans, statistcs, metadata, right down to what version of the database you're using.
    Now, you already have been provided with links to helpful threads: these explain how you can proceed in collecting this information and investigating your problem. The sooner you start reading those links the sooner you can start diagnosing the poor performance.
    If you still can't crack it, by all means post here again. But don't bother until you have gathered all the ibnformation you need to [post so that we can understand your situation.
    Cheers, APC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I m Not able to access to create database, Please solve the problem. please give some text steps

    ===================================
    Create failed for Database 'Qlao'.  (Microsoft.SqlServer.Smo)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1750.9+((dac_inplace_upgrade).101209-1051+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476
    Program Location:
       at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CreateImpl()
       at Microsoft.SqlServer.Management.Smo.Database.Create()
       at Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabaseData.DatabasePrototype.ApplyChanges(Control marshallingControl)
       at Microsoft.SqlServer.Management.SqlManagerUI.CreateDatabase.DoPreProcessExecution(RunType runType, ExecutionMode& executionResult)
       at Microsoft.SqlServer.Management.SqlMgmt.SqlMgmtTreeViewControl.DoPreProcessExecutionAndRunViews(RunType runType)
       at Microsoft.SqlServer.Management.SqlMgmt.SqlMgmtTreeViewControl.ExecuteForSql(PreProcessExecutionInfo executionInfo, ExecutionMode& executionResult)
       at Microsoft.SqlServer.Management.SqlMgmt.SqlMgmtTreeViewControl.Microsoft.SqlServer.Management.SqlMgmt.IExecutionAwareSqlControlCollection.PreProcessExecution(PreProcessExecutionInfo executionInfo, ExecutionMode& executionResult)
       at Microsoft.SqlServer.Management.SqlMgmt.ViewSwitcherControlsManager.RunNow(RunType runType, Object sender)
    ===================================
    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
    Program Location:
       at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
       at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
       at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
       at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ExecuteNonQuery(StringCollection queries, Boolean includeDbContext)
       at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CreateImplFinish(StringCollection createQuery, ScriptingOptions so)
       at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CreateImpl()
    ===================================
    CREATE DATABASE permission denied in database 'master'. (.Net SqlClient Data Provider)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1617&EvtSrc=MSSQLServer&EvtID=262&LinkId=20476
    Server Name: SLPSOFTSOLS1
    Error Number: 262
    Severity: 14
    State: 1
    Line Number: 1
    Program Location:
       at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
       at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)

    Hello,
    This issue might be caused by the User Account Control (UAC) settings if we use Windows 7 or Windows Server2008, ect Operating System. Please also take a look at the following articles:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/28fee0ed-c7e2-40df-8f79-f513c9848f09/create-database-permission-denied-in-database-master-microsoft-sql-server-error-262?forum=sqltools
    http://blogs.msdn.com/b/dparys/archive/2009/09/17/create-database-permission-denied-in-database-master-my-fix.aspx
    Regards,
    Elvis Long
    TechNet Community Support

Maybe you are looking for

  • Translations into a transport request

    Hi all, The question has been asked before here at this forum, but I haven't found a satisfacory answer yet. I have to change the translations of some smartform texts using se63. After having made the changes, I am not forced to add the changes into

  • HP printer driver not working with 10.8.2

    Can anyone give me advice on how to make my all in one laserjet HP printer M2727nf work in 10.8.2.  Downloaded new driver software on January 10, since the new OS software update today again the printer is no longer connecting.  I have given up on th

  • MSI GE70 Apache Pro unboxing

    Here we have the awesome MSI GE70 Apache Pro (GE70 2PE-051UK) for our unboxing! As you can see it has all the trademark MSI logo, slogan and some of the other world class brands which feature on this notebook such as the Killer network who provide th

  • Request StockMaster app for desktop

    The StockMaster app for iPhone is awesome. Yahoo Finance has recently really messed up its charting function, and StockMaster has the solution. Yahoo Finance is not responding to the flood of complaints about it's charting changes. Would like to have

  • Is it ok to charge iphone many times a day?

    i always want to have a full battery, is it ok to charge the iphone many times every day(4-5 times)?