Problem While Writing Query

Hi:
There are three tables,
*1.TbReg*
reg_no,reg_name
Data:
RO1 Reg1
RO2 Reg2
RO3 Reg3
*2.TbZbr*
br_no,reg_no
Data:
092 RO1
013 RO1
020 RO3
*3.TbLM_Mast*
LM_no,br_no
Data:
1 013
2 013
3 020
Required O/p:
Reg_name | NoOfLeads |
RO1 | 2 |
RO2 | 0 |
RO3 | 1 |
From Above tables i want to write query for,
select total number of leads available in TbLM_Mast against each branch(*br_no*) from TbZbr,
and compare same reg_no with TbReg table and display required O/p/
So, how to write this query...?
Can any body help me...
Thank You,
Anup Desai

How about this:
with TbReg(reg_no,reg_name) as
(select 'RO1','Reg1' from dual union all
select 'RO2','Reg2' from dual union all
select 'RO3','Reg3' from dual
TbZbr(br_no,reg_no)
as
(select '092','RO1' from dual union all
select '013','RO1' from dual union all
select '020','RO3' from dual
TbLM_Mast(LM_no,br_no)
as
(select 1, '013' from dual union all
select 2, '013' from dual union all
select 3, '020' from dual)
SELECT TbReg.Reg_No,COUNT(TbLM_Mast.br_no)
FROM   TbReg
LEFT OUTER JOIN TbzBr
ON TbzBr.reg_no = TbReg.reg_no
LEFT OUTER JOIN TbLM_Mast
ON TbLM_Mast.br_no = TbzBr.br_no
GROUP BY TbReg.Reg_No

Similar Messages

  • Problem while writing data on xls file using jxl API

    Hi,
    I am getting problem while writing data on excel file using jxl api.
    When i write data on file and all handles associated to the file are closed, file size increases but when i open the file nothing is written in it and when file is closed manually from excel window, file size decreased to its original that was before writing data.
    here is code:
              FileOutputStream os = new FileOutputStream(this.dirPath + this.fileName, true);
              WritableWorkbook this.workbook = Workbook.createWorkbook(os);
    after writing data following handler are closed:
    this.os.flush();
                        this.workbook.write();
                        this.workbook.close();
                        this.os.close();
                        this.os = null;
    can any body help me.
    Thanks in advance

    Err, I did help you. I did understand your problem; and I solved it for you. What was missing was that you apparently made no effort to understand what you were being told. Or even consider it. You just argued about it, as though you were the one with the solution, instead of the one whose code didn't work.
    And the other thing that was missing was the part where you said 'thank you' to me for solving your problem. Somewhat more appropriate than biting the hand that fed you, frankly. I do this for nothing, on my own gas, and it's extremely irritating when people keep asking about problems I have already solved for them. I am entitled to discourage that. It's part of making them more efficient actually.
    But it happens often enough that it also makes me think I'm just wasting my time. Probably I am.

  • Problems while writing to file

    Hi,
    I'm trying to query my test database (mysql) and to write these results to a file, I manage to get the results out of the database, but when I try to write for instance an int to a file, the file replaces the int by a square. What can be wrong?? The file is created successfully and I've writen the int to the standard out before writing it to the file; in the standard out the int is correct.
    code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class getData extends HttpServlet {
    FileWriter fw;
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    } catch(Exception e){
    System.err.println("Database driverclass not found");
    Connection conn;
         //insert values into DB
    try {
         conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=admin12&password=adm12");
    Statement stmt = conn.createStatement();
    String slq = "Select * from feedback";
    ResultSet rs = stmt.executeQuery(slq);
    if (rs==null){System.out.println("nOT OK");}
    else{
    try{
    File f = new File("D:\\mysql\\Data.txt");
    fw = new FileWriter(f);
    while(rs.next())
    writeToFile(rs.getString(1));
    writeToFile(rs.getString(2));
    writeToFile(rs.getInt(3));
    writeToFile(rs.getInt(4));
    writeToFile(rs.getString(5));
    writeToFile(rs.getInt(6));
    catch(IOException e)
    System.out.println("Error occured while writing to file");
    stmt.close();
         conn.close();
    } catch(SQLException sqle){
    System.err.println("A SQL error has occured: " + sqle.getMessage());          
    /* output your page here*/
    out.println("<html>");
    out.println("<head>");
    out.println("<title>getDataServlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h2>Data recovered</h2>");
    out.println("</body>");
    out.println("</html>");
    out.close();
    fw.flush();
    fw.close();
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    private void writeToFile(int i)
    try{
    System.out.println("test: "+i);
    fw.write(i);
    fw.write(";");
    }catch(IOException e1)
    private void writeToFile(String str)
    try{
    if (str!=null&&(str.equals("null")==false)){
    fw.write(str);
    fw.write(";");
    }catch(IOException e2)

    I would imagine that FileWriter is writing the byte value to the file. Just change your SQL get to this writeToFile(rs.getString(6)); and write it as a String instead of an int.
    DesQuite

  • Problem while writing to fixed length flat file from xml

    Hi,
    I have a problem in writing data into a flat file of fixed length...
    My input is a xml file and i want the output as a flat file. I am successful in converting the xml into flat file... But the main problem is, i am unable to insert spaces in between my fields in the flat file.
    The data in the flat file comes without spaces... Any suggestions on writing the schema...
    Regards
    Surya.

    Have a look at this doc
    http://otndnld.oracle.co.jp/document/products/as10g/101310/doc_cd/integrate.1013/b28994/nfb.htm#BGBBAJFD
    your element should be something like this, it pads with a space using the paddedBy expression
    <xsd:element name="C1" type="xsd:string" nxsd:style="fixedLength" nxsd:length="4" nxsd:paddedBy=" " nxsd:padStyle="tail" />if having trouble post what you want the file to look like, and the xsd you are using.
    cheers
    James

  • BI 7.0 Problem while executing query on Infoset containing Infocubes

    Hi All,
    While executing quey on infoset containing infocubes we are getting following error message.
    EError while reading data; navigation is possible
    EError reading the data of InfoProvider A2PPI103
    EError when generating the SQL statement
    E[IBM][CLI Driver][DB2] DSNT408I SQLCODE = -204, ER ROR:  SAPR3.T00001 IS
    I>> Row: 11 Inc: RAISE_READ_ERROR Prog: CL_RSDRV_VPROV_BASE
    any idea what could be the reason ?

    Hi All,
    it's very interesting the question of HariPrasad because from yesterday i have the same problem in  a similar environment:
    @5C\QError@     Error reading the data of InfoProvider ZC1ITS02
    @5C\QError@     Error when generating the SQL statement
    @5C\QError@     [IBM][CLI Driver][DB2] DSNT408I SQLCODE = -204, ERROR:  SAPBWD.T00002 IS AN UNDEFINED NAME  DSNT41 8I SQLSTATE   = 42704 SQLSTA
    May the SQL generator does'nt work well whit cube and DB2 ??
    If i execute the Infoset with the debbugging option i can see the SQL code:
    ...........FROM "/BIC/PZC1CPROD0" "T00001",
    "T00002"
    WHERE................
    the first table is an infoobject, the second one is the "missing" cube...............
    Hari, did you solve the problem in the meantime ??
    Thank's to all, Ray.

  • Problem while writing the data (LSMW direct input method for Creating BOM )

    Hi all ,
    I am unable to create a BOM using LSMW standard dirrect input mehtod .
    While i going through the *Read data *  step , it is reading the data but unable to write the data .
    My input text files are correct , Is it a problem with respect to the Logical Path or Logical File ......
    Please let me know the Possibilities of arising this problem .
    Regards,
    Raj

    Hi,
      Check this document:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/90d90895-68dd-2a10-f096-bf8cf2e2f65b
    cheers
    Aveek

  • PROBLEM IN WRITING QUERY.

    HI FRIENDS,
    I AM TRYING TO WRITE A QUERY WHICH WILL RETURN ME DATE QUATER WISE.
    SUPPOSE I HAVE A DATE 19-SEP-12 THEN IT WILL CONSIDER THIS DATE BETWEEN FINANCIAL YEAR 2012-2013 AND THE RETURN ME DATE LIKE
    01-APR-12 TO 30-JUN-12
    01-JUL-12 TO 31-SEP-12
    01-OCT-12 TO 31-DEC-12
    01-JAN-13 TO 31-MAR-13
    PLEASE HELP ME IN WRITING THE QUERY.

    Hi,
    If
    TRUNC (date_column, 'Q')is the beginning of quarter x, then
    ADD_MONTHS ( TRUNC (date_column, 'Q')
            , 3
            )is the beginning of quarter x+1, and
    ADD_MONTHS ( TRUNC (date_column, 'Q')
            , 3
            ) - 1is the last day of quarter x.
    The expression above is midnight at the beginning of the last day of quarter x; be careful if you use it in a BETWEEN expression.

  • Time Stamp problem while writing data into the excel file

    Hii, All
                  I am taking the data from the DAQ card of the TOPSCCC with the 8 ms of scanrate for each channel and there are total 16 no of Analog channels in the Card, now i am acquiring the data from the card, time stamping it and writing it into the excel file, which is tab delimited, now the problem is, the data which are in the excel file have the same timestamp for 4 to 5 continuous records, instead we want each data with the different and continuous time stamp with same difference of time stamp between two records, mean if it is difference of 8 ms then it should be the 8 ms for all, but here it is taking the differnce of 16 ms for two samples and giving same time stamp for four to five records and that shouldn't happen, here i am attaching my vi, drivers for the cards and Excel file with the data, can you please give me any suggestion how to do it?
           Please help me i require this suggestion as early as possible, i am requiring it urgently.
    Thanks in Advance,
    Nishant
    Attachments:
    2026vi.llb ‏319 KB
    2026_ScanMultAD_Demo_time.vi ‏80 KB
    Data.xls ‏357 KB

    Hello Nishant,
    that's what I meant:
    Message Edited by GerdW on 05-16-2006 10:32 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    timestamp-array.png ‏2 KB

  • Problem while runnning query on 0TCT_MC11

    Hi,
    While reading data from 0TCT_MC11 through query I am getting the following message...
    "Error while reading data; navigation is possible
    "Value XY2CLNT400AHPL_ACCT"
    "You are trying to load the invalid characteristic value 1. (hexidecimal representation 0044004200320043004C004E00540036003000300049004F00)."
    Please let me know if you have any suggestions for this.
    Thanks, Jeetu

    Jeetu,
       It seems like there are some data records with speical characters loaded into one the cubes in 0TCT_MC11.
    hope it helps,
    Balaji

  • Problem while writing BDC Code......

    Hi All,
    I am writing a BDC Code to call transaction: PRFI.
    Ones the transaction is run(from GUI directly) for a particular trip number, the status of the trip gets changed to Docs Created. On the other hand while doing the same using the BDC method, the status that is getting generated is: Selection is Running.
    It looks as if the transaction is not getting committed properly.
    I am writing the BDC very correctly and also screen sequences are trapped properly.
    Please help.
    Abhi.
    Edited by: Digvijay Sharma on Jul 29, 2010 12:14 PM

    Hi,
    You saying that all screens and flow logic will be written properly.
    use SHDB for recording that transaction then compare each Dynpro and all the things.
    It will be helpful for you.

  • Problem while writing image to disk..............

    AOA
    in my application i scan an image and then try to write it to c:\image folder in windows then it gives following exception.
    java.io.FileNotFoundexception: c:\image (Access is denied)
    i have checked the security and permissions for C.
    they allow the user to write but problem is still there.
    what may b the reason

    If I use the following code:
    try {
        FileWriter out = new FileWriter("C:/DRIVERS");
    } catch(IOException ioe) {
        ioe.printStackTrace();
    I get
    java.io.FileNotFoundException: C:\DRIVERS (Access is denied)======================================================
    The above is have relative path in
    FileWriter out = new FileWriter("C:/DRIVERS");instated of giving relative("C:/DRIVERS") path you just give the absolute
    path.
    FileWriter out = new FileWriter("C:/DRIVERS/filename/yourscanimage");

  • Problem while transporting query from development  to quality

    Hi ,
    At the time of collecting objects, we are getting an error.
    Object '48NYONN6RPXN7Q9YDS6DWSM35' (ROUT) of type 'Routine' is not available in version 'A'
    (Infact similar error statements round 16 are displayed).
    I don't see any object as such.
    i don't understand what the problem is? pls help.
    Rgds,
    Raghu

    Hi
    Go to table RSZCOMPDIR and enter this in the comp id
    48NYONN6RPXN7Q9YDS6DWSM35
    it will give you the technical name of the variable or the report .
    if it is variable transport the variable first and then transport the report.
    This will solve your problem.
    Reggards
    RaM

  • Problem while writing to file

    I have a value '2222.12' stored in a database table. i fetch this value and write this value to a file but in file the value is '2222,12' instead of '2222.12'. i.e dot is being replaced with a comma automatically, can anyone tell what is the mistake i am making?????
    my code is for writing to file is:
    Sys.UTL_FILE.PUT_LINE (file_handle,my_cursor.amount);

    To answer any question at a minimum you need to post
    4 digit Oracle version (from select * from v$version)
    OS and version
    In this particular case : regional settings when running on Windows
    Apparently you are writing a number and you are relying on implicit conversion to a character string, as put_line writes strings only.
    You may want to use explicit conversion and use to_char(my_cursor.amount,'99999.09')
    Sybrand Bakker
    Senior Oracle DBA
    Edited by: sybrand_b on 21-apr-2010 7:11

  • Problem while designing query please help

    Hi all,
    I have to query to find No of open cases, No of closed cases,
    Average of open cases, Average age of closed cases,
    Maximum of closed cases for a particulat Current assigne(char).
    my desired output is as follows.
    CurAssigne   Noofopencases   Noofclosed cases  Avgage(opencases) Max(open)
    CurAssigne1       10                      20                     8                              9
    CurAssigne1       18                      22                     9                              10
    My cube is consists of.
    4 Dimensions & 4 key figures
    4Dimensions are listed below.
    Business Partner{currentassigne, previousassigne,acmanager}
    createdon{createdonmonth,createdonday,createdtime}
    closedon{closedmonth,closedday,closedtime}
    Status{Latest case status-(2 status are available for each case - open,close)}
    above the objects between {} are chars.
    4 keys are listed below.
    no of cases.
    age
    first response time
    research time.
    Please help me to design this query friends..
    It's very urgent friends please help me.

    Hi,
    Please share your system configuration on which you are trying to install Ps CS6.
    Regards,
    Ashutosh
    Ps Installer QE

  • Problem while executing query in BEX

    Hello Experts .
    Whenever I execute the standard query based on info cube 0PA_C01 in bex it gives following message for first time , but if excute the same query second time it wont gives the msg . Pls it is very urgent .
    msg :
    Characteristic 0CALMONTH was changed in InfoCube 0PA_C01. Adjust the query
    Characteristic 0EMPLOYEE was changed in InfoCube 0PA_C01. Adjust the query

    Hello Raghavendra,
    welcome aboard!!
    You need to make the change globally and save it by going in the change mode.
    when u next time execute the same after relogin u wont face this issue.
    Hope it helps...
    thanks,
    (pls. dont forget to assign points for helpful answers)

Maybe you are looking for

  • Two disk drives to act as one?

    Hello, I know I might get a LMGTFU for this but what I've looked up so far has been pretty technical and was hoping to get a more simplified explanation.  I just got a second hard drive and it's faster and larger than the original that came with it. 

  • Trying to understand StreamReader (BinaryReader) BaseStream Position

    This is my first attempt to use BinaryReader in VB 2012 (having previously done so in VBA). I am reading an extremely large text (TSV) file which I ultimately intend to divide into many more manageable-sized files that (in the future) I want to be ab

  • Spotlight failure

    Spotlight has just completely stopped working on my MacBook - it will still launch, but when I enter text it returns with no results (even for easy things, like Text Edit). MacBook is fully updated with OS X etc versions etc. I've tried re-indexing m

  • I can't see all my movies from my itunes library

    When i go to "Purchased" movies on my apple tv, only 2 movies show up from a library of purchased movies of about 20. Can anyone help?

  • B109 will not sync with laptop

    Your printer has limited connectivity. Your printer is using IP address 169.254.162.45, which is not compatible with the IP address 192.168.0.5 of the PC.  Power off your printer and then power on and wait 60 sec for the printer to acquire an IP addr