Sub query not executing

i am running these SQL lines but getting error but this DISCH_SUM_ID is there in my table
disch_sum_hdr
select disch_sum_hdr.*,
SELECT CASE NVL(Disch_sum_Dtl.Disch_Res_Col_1,0) WHEN 1 THEN 'DEATH SUMMARY'
ELSE 'DISCHARGE SUMMARY' END As DiscSummTitle
from Disch_sum_Dtl
LEFT JOIN Disch_sum_Dtl Disch_sum_Dtl_1
ON Disch_sum_Dtl_1.DISCH_SUM_ID = Disch_sum_Hdr.DISCH_SUM_ID
) as DiscTitle
from disch_sum_hdr
Error
ORA-00904: "DISCH_SUM_HDR"."DISCH_SUM_ID": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:   
*Action:
Error at Line: 7 Column: 45

Like Sylvie, I'm not sure what you are trying to do, but I think what you are looking for is more like:
select disch_sum_hdr.*,
       (SELECT CASE NVL(Disch_sum_Dtl.Disch_Res_Col_1,0) WHEN 1 THEN 'DEATH SUMMARY'
                  ELSE 'DISCHARGE SUMMARY' END As DiscSummTitle
        from Disch_sum_Dtl
        where Disch_sum_Dtl.DISCH_SUM_ID = Disch_sum_Hdr.DISCH_SUM_ID) as DiscTitle
from disch_sum_hdrYou do not need a join in the scalar sub-query here. If that is what you want, then I would be inclined to write it as a straight outer join like:
select disch_sum_hdr.*,
       CASE NVL(Disch_sum_Dtl.Disch_Res_Col_1,0)
          WHEN 1 THEN 'DEATH SUMMARY'
          ELSE 'DISCHARGE SUMMARY' END As DiscTitle
from disch_sum_hdr
   left join Disch_sum_Dtl
      on Disch_sum_Dtl.DISCH_SUM_ID = Disch_sum_Hdr.DISCH_SUM_IDwhich is likely to be more efficient.
John

Similar Messages

  • Joining with sub query not working

    Hi
    I am new with these complex queries. I am trying to join a sub query to a query as below;
    SELECT Events1.InvoiceBatch AS BatchNo, Events1.InvoiceBatchDate AS BatchDate, tblClients.Company, tblClients.ID AS ClientID, COUNT(Events1.ID) AS Invoices,
    COUNT(*) - COUNT(Events1.InvoicePrintDate) AS E, Events1.InvoiceBatchFromDate AS BatchFrom, Events1.InvoiceBatchToDate AS BatchTo, (SELECT EventID, SUM(Total) FROM tblStaffBookings AS StaffBookings WHERE StaffBookings.EventID = Events1.ID GROUP BY EventID) AS Total
    FROM tblEvents AS Events1 LEFT OUTER JOIN
    tblClients ON Events1.ClientID = tblClients.ID
    WHERE (Events1.FactoringExportDate IS NULL) OR (Events1.AccountsExportDate IS NULL) OR (Events1.InvoiceSentDate IS NULL)
    GROUP BY Events1.InvoiceBatch, Events1.InvoiceBatchDate, tblClients.Company, tblClients.ID, Events1.InvoiceBatchFromDate, Events1.InvoiceBatchToDate
    HAVING (Events1.InvoiceBatch = 5212)
    ORDER BY tblClients.Company
    I am getting these two errors;
    Msg 8120, Level 16, State 1, Line 2
    Column 'tblEvents.ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
    Msg 116, Level 16, State 1, Line 2
    Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
    What am I missing?
    Thanks
    Regards

    SELECT Events1.InvoiceBatch AS BatchNo, Events1.InvoiceBatchDate AS BatchDate, tblClients.Company, tblClients.ID AS ClientID, COUNT(Events1.ID) AS Invoices,
    COUNT(*) - COUNT(Events1.InvoicePrintDate) AS E, Events1.InvoiceBatchFromDate AS BatchFrom, Events1.InvoiceBatchToDate AS BatchTo,Total
    FROM tblEvents AS Events1 LEFT OUTER JOIN
    tblClients ON Events1.ClientID = tblClients.ID
    LEFT OUTER JOIN (SELECT EventID, SUM(Total) AS Total FROM tblStaffBookings AS StaffBookings WHERE StaffBookings.EventID = Events1.ID GROUP BY EventID) sb
    ON sb.EventID = Events1.ID
    WHERE (Events1.FactoringExportDate IS NULL) OR (Events1.AccountsExportDate IS NULL) OR (Events1.InvoiceSentDate IS NULL)
    GROUP BY Events1.InvoiceBatch, Events1.InvoiceBatchDate, tblClients.Company, tblClients.ID, Events1.InvoiceBatchFromDate, Events1.InvoiceBatchToDate,Total
    HAVING (Events1.InvoiceBatch = 5212)
    ORDER BY tblClients.Company
    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
    Says;
    Msg 4104, Level 16, State 1, Line 5
    The multi-part identifier "Events1.ID" could not be bound.
    on
    LEFT OUTER JOIN (SELECT EventID, SUM(Total) AS Total FROM tblStaffBookings AS StaffBookings WHERE StaffBookings.EventID = Events1.ID GROUP BY EventID) sb
    Regards

  • QBE style(Find-Execute) Query not executing when VO has bind parameter

    I have an Entity Based ViewObject that is composed of 3 Entities so the entities are related through an Assoc. Then the ViewObject also has a bind paremeter defined and used in the WHERE clause.
    In my page everything is fine until when I use/click on the Find operation on the JSF page. When the Find operation is executed the page/form goes blank so I can enter by QBE query. Now when I Execute my search by executing the ExecuteWith params operation. Nothing is happening to the screen, it seems that query was not executed. Although there was no errors or exceptions displayed.
    However if I remove the bind parameter, and execute the Execute operation instead after going to Find mode, the query is executed properly and I get expected results.
    My problem is a bit general, but are there anyone who had a similar problem like this? Im still in the process of creating a test case.
    regards,
    Anton

    Hi Frank,
    But the "ExecuteWithParams" operation provides the bind variable right? (i had the value hardcoded on the pagedef). So it must have supplied a value. I also noticed that this is happening only when if the VIewObject contains two or more Entities. If the Viewobject has only 1 entity, the ViewObject queries properly.
    Anyway Frank, I had found a fix for this. I set an InvokeAction on the pagedef that binds to the ExecuteWithParams that is invoked during page load only(!postback condition). and then I just use the Find-Execute operations instead of the Find-ExecuteWithParams operations that I used previously.
    I will try to replicate the issue again to investigate what's really going on. I just want to know if its a bug or just an expected behavior or i just made a mistake.
    regards,
    Anton

  • Database migration query not executing in database

    We moved over our SQL database to another server. We have a few .cfm template files that have queries to get 'content' from our database. These queries in the .cfm template files work fine and execute properly. However, for some reason, since we moved over our database, the queries in the actual database don't execute/run anymore. In the old server we didn't have this problem. Our queries in the database would run properly then. The data would display correctly on the webpages.
    Is there some kind of properties setup that was overlooked when migrating over our database?
    The output we now see when viewing our pages is the actual query code.
    Example:
    SELECT lname
    FROM table
    This is actually displayed on the website and therefore the query is not executing/running. Our code was never changed. So why is it not outputting the same?
    Thanks for any help provided.

    Sorry for the confusion.
    The coldfusion templates and database queries both worked fine on the previous old server.
    Now since the migration onto the new server, only the coldfusion templates work fine, but not the queries in the database.
    So for example, a query in the coldfusion template will run fine, and execute the intial pull of data. But once the content is pulled from the database, the queries inside the database (including stored procedures) don't execute.
    We do get the expected results when we run our stored procedure in Management Studio and if we put the stored procedure on a standalone web page we do see the records. 
    We only see the sql code when we have the stored procedure inside of our w_content table of our database, and its being called by the first query in the template.  For some odd reason the stored procedure does not execute if it is inside the database.  
    Hopefully that clarifies our problem.
    Thank you for helping!

  • Query not executing for one particular value

    Hi
    I have query on multi provider. and this multi provider is combination of Info objects only but not any ODS or cubes. I have one key figure in this multi provider.while executing the query i need to give input for variabl which has 7 different values. Query is executing fine for 6 values but not for one particular value.
    query executed in listcube transaction and it is executed fine here for the same selection. then what might be the reason?
    Please advise as soon as possible.
    Thanks

    Hi Kiran,
    are you maintaining any filters in the query? or is there any logic in the exit for this variable.
    regards.

  • Trigger query not executed and havenot any exception

    Hello all,
    I am using oracle 10g lite database, and i m firing a create trigger query, but it is not executed on console, when i try at console at this trigger query after that no one query will fire,
    Plzzzzzzzzzzzzzzzzzzz help me
    my used table is
    1. create table t1 ( c1 int, c2 int);
    2. create table t2 (c1 int, c2 int);
    3. Create trigger System.check after insert on system.t1 For each Row begin Insert Into system.t2 ( c1,c2 ) Values (1,1) ;end ;
    Thankx in advance
    Pankaj

    Triggers are supported on the client side in newer versions:
    11.2.1 Creating Java Stored Procedures
    To create a stored procedure, perform the following:
    1.
    Create the class that you want to store in Oracle Database Lite. You can use any Java IDE to write the procedure, or you can simply reuse an existing procedure that meets your needs.
    When creating the class, consider the following restrictions on calling Java stored procedures from SQL DML statements:
    When called from an INSERT, UPDATE, or DELETE statement, the method cannot query or modify any database tables modified by that statement.
    When called from a SELECT, INSERT, UPDATE, or DELETE statement, the method cannot execute SQL transaction control statements, such as COMMIT or ROLLBACK.
    Note:
    Any SQL statement in a stored procedure that violates a restriction produces an error at run time.
    2.
    Provide your class with a unique name for its deployment environment, since only one Java Virtual Machine is loaded for each Oracle Database Lite application. If the application executes methods from multiple databases, then the Java classes from these databases are loaded into the same Java Virtual Machine. We recommend that you prefix the Java class name with the database name to ensure that the Java class names are unique across multiple databases.
    3.
    If you are executing any DML statements in your Java stored procedure, then—in order for these statements to exist within the same transaction—you must pass an argument of type java.sql.Connection as the first argument in the method. You must have the Connection object in order to prepare and execute any statements. Oracle Database Lite supplies the appropriate argument value of the Oracle Lite database Connection object for you; the application executing the method does not need to provide a value for this parameter.

  • Sub query not allowed

    hi
    I have a package
    create package pack1
    procedure proc1(empid varchar2(10),ename varchar2(20),joindate date,empcat varchar2(20))
    is
    begin
    declare
    cursor c1 is
    select.....
    begin
    case when joindate>=(select joindate from empdetails where eid=empid)
    dbms_output.put_line("not vaid");
    when empcat not in(select ecat from empcategory where eid=empid)
    dbms_output.put_line("not vaid");
    end case
    end proc1
    end pack1
    here for the case statements it says sub queries not allowed
    can any one help what to do for validating input joindate and empcat.
    Once they are invalid I should print error message and exit from the process
    thank you

    create package pack1
    procedure proc1(empid varchar2(10),ename varchar2(20), ajoindate date,empcat varchar2(20))
    is
    -- begin
    -- declare
    valid number;
    cursor c1 is
    select.....
    begin
    select count(*)
    into valid
    from empdetails where eid=empid and ajointdate >= joindate;
    if number > 0 then
    dbms_output.put_line("not vaid");
    end if;
    select count(*)
    into valid
    from empcategory where eid=empid
    and empcat = ecat;
    if valid = 0 then
    dbms_output.put_line("not vaid");
    end if;
    end proc1;
    end pack1;

  • Simulation interface toolkit: SUB VI not executable error

    Hi;
    I have a real-time application where I model things in Simulink and use Simulation Interface Toolkit to carry out hardware-in-the-loop simulations. As a real-time target, I am using NI-PXI8106 with NI-PXI6251 DAQ card on it. Up until now, I was able to run my code just fine. However, for some reason, my vi didn't work today and gave several errors such as:
    SubVI NI_SIT_sitclient.Lvlib:RVE.vi: SubVI is not executable
    Details:The SubVI is not executable. You must fix all error in the subVI before this VI can run.
    SubVI NI_SIT_sit Init Model.vi: SubVI is not executable
    Details:The SubVI is not executable. You must fix all error in the subVI before this VI can run.
    This is just few of many error that I received...In the details section of the error list window, the error statement are usually like the following:
    SUBVI not supported for current target..
    Type not supported in the current target...
    The only thing that changed since the last time I ran this program with success is the IP change of the target machine..However, when I use Measurement and Automation tool, I am able to access my target machine (PXI8106) without a problem...Maybe there are some certain rules for IP settings on the PXI target? ...I can provide the details of my new IP configuration numbers if necessary...
    I also  reinstalled the SIT 5.0 on the target machine but It didn't do the trick. I am wondering if there is anyone out there who can help me out with this problem..
    Thank you so much!
    Kind Regards.

    Hi there,
    I was just wondering if you did manage to solve this problem. I'm a new user and have recently started using the Simulation interface toolkit. I have created my model using Simulink and used the real-time workshop to convert it to a .dll file. I tried to run it on labview and it seems to build it on the realtime target, however as soon as map it to the hardware (using a NI BNC-2111,It's just a bunch of analog inputs and output which I have connected to a voltmeter), a dialog box pops up with the the following error:
    Error 1003 occurred during host VI initialization: SIT_test1.vi >> NI_SIT_sitclient.lvlib:sit Init Model.vi >> NI_SIT_sitclient.lvlib:sit Connect to Target.vi
    <append>=========================
    Simulation Interface Toolkit:  The driver VI (SIT_Test_Driver.vi) is not executable.
    Check the following:
    1) You have not modified the driver VI.
    2) You properly installed SIT and any necessary driver software on the target.
    3) The target has not been locked from Measurement and Automation Explorer.
    Do you want to launch the SIT Connection Manager dialog box and reconfigure the simulation?
    Please look at the JPEG picture attached below to see how the error looks on my monitor.
    Thanks
    Attachments:
    error1.JPG ‏135 KB

  • Oracle 8i - PL/SQL sub query not working in PROC, but works ins SQL

    I have read about certain things not working in 8i and I think this is one of them, but I was wondering if anyone had a work around. In the place of the SELECT SYSDATE FROM DUAL, I have a table look up, where I am going to look up the OCN of the corresponding VENDOR_ID ( a column in the original query ). I am doing it in a decode statement because if the first condition in the decode statement is met, that's it. But if not, it needs to look up the OCN number in this other table. Simple enough, conceptually. I thought of a view but that necessitates a SELECT statement, too. Anyway, here is the code with the appropriate text bolded:
    CREATE OR REPLACE PROCEDURE tstINS_RATE_ROUTE_RECORDS_PROC (GET_CUR_PERIOD IN DATE) IS
         CUR_PERIOD DATE;
         BEGIN
         CUR_PERIOD := GET_CUR_PERIOD;
         Insert into RATE_ROUTE (
           CVBI_KEY
         , VENDOR_ID
         , OCN
         , ST_CD
         , PERIOD
         , MDFY_DT )
         Select
           C.CVBI_KEY
         , C.VENDOR_ID
         <b>, decode( c.send_lca, 'YES', 'XXX', (SELECT SYSDATE FROM DUAL) )</b>
         , decode( c.send_lca, 'YES', 'XX', SUBSTR(C.ZLOC,5,2) )
         , CUR_PERIOD
         , TO_CHAR(SYSDATE)
         FROM
           rpt_ds1_cnt_cat c
         , cogs_resource cr
         , cogs_t1activity ct1
         , rpt_ds1_aloc_zloc_reverse_vw az
         where (C.CVBI_KEY = CR.CVBI_KEY (+)
         and  CR.PERIOD = CUR_PERIOD)
         AND  (C.CVBI_KEY = CT1.CVBI_KEY (+)
         and CT1.PERIOD = CUR_PERIOD)
         and (az.master_route_name=c.aloc||'-'||c.zloc OR az.reversed=c.aloc||'-'||c.zloc)
         END; -- INS_RATE_ROUTE_RECORDS_PROC

    have read about certain things not working in 8i and I think this is one of them,Yes as I said scalar sub-queries were also not recognized within PL/SQL in 8i.
    Re: PLS-00103: Encountered the symbol "SELECT" when expecting one of the fo
    I was wondering if anyone had a work around.Write a function that returns the value. You may incur a performance penalty from a context switch to PL/SQL, but it may be balanced by the decode optimization you are attempting.

  • Query not executing the results

    Hi,
    I have created a Custom Virtual Cube with a custom function module. This Cube displays data when i check it through the transaction code - LISTCUBE.
    I have a query which has to be executed on this Virtual Cube. When i execute this Query , it does not display any data at all. It always displays "No applicable data found".
    I have tried with the combination of inputs for which the data is available in the cube. but still it gives "No applicable data found".
    Can someone suggest me what i have to do to correct this problem.
    Thanks
    Maddy

    Hi Maddy,
    I also encountered similar problem in BI 7.0, which doesn't happen in BW 3.5, though I was using Basic Cube, not Virtual Cube. I could finally work it out. Here are the steps I used:
    - Right click on the InfoCube > choose "Manage".
    - In the "Requests" tab, click the traffic light button in the "Request Status" column, set it to "Status OK".
    - The "Request for Reporting Available" column will show the "Request is available for reporting" icon automatically.
    - Try to execute your query again.
    Hope this might be relevant to your situation as well.
    Regards,
    arie

  • Query not executing all columns

    Hi Experts
    My client is running a query. they have been using it for a little while now with no issues. I have attached the query as a formatted search on the item master data form. when one of their users runs the queriy through the formatted search, it doesnt show the last column. but when running it through the query manager, it works fine.
    its only giving this problem for the one user (doesnt matter if we log in as that user on his PC or any other PC) therefore it is user related.
    why could this be happening?

    OK below is the query:
    declare @CurUser as nvarchar(10)
    set @CurUser = $[user]
    if(@CurUser in (1,5,8,9,22,44
    begin
    with req as
    select [item number] as 'item',[required qty] as 'required', [forecast current month] as 'forecast', [sq] as 'SQ', [on hand]
    FROM VPP_2006SBO_GARSINLIVE.DBO.VLGX_GetPlannedItemDetails()
    Invoices AS  --Get invoices per item
    *(SELECT T0.[ItemCode], T0.[FrgnName], SUM(I1.[Quantity]) AS Qty,*
            *DATEDIFF(month, T0.CreateDate,getdate()) AS ItemMonths*            
       *FROM OITM T0  full outer join inv1 i1 on T0.ItemCode = I1.ItemCode*
                     *left join OINV I0 ON I0.DocEntry = I1.DocEntry*
      *WHERE I0.[DocDate] >= '2006-06-01'*
        *AND I0.DocType <> 'S'*
      *GROUP BY T0.[ItemCode], T0.[FrgnName], T0.CreateDate*
    *Credit AS               -- Get credit notes per item*
    (      SELECT C1.[ItemCode],
    *                C1.[Dscription],*
    *                SUM(C1.[Quantity]) AS Qty*
    *          FROM ORIN C0  INNER JOIN RIN1 C1 ON C0.DocEntry = C1.DocEntry*
           WHERE C0.[DocDate] >= '2006-06-01'
                 AND C0.DocType <> 'S'
          GROUP BY C1.[ItemCode], C1.[Dscription]
    ItemInfo As
    (SELECT T0.ItemCode[SearchCode], t0.ItemName,T0.FRGNName[Description], cast (cast ((T0.OnHand- T0.IsCommited) as decimal (5,0)) as nvarchar (10))[Available], cast (cast (T0.OnOrder as decimal (5,0)) as nvarchar (10))[Expected],
    (case when (T0.U_IMP is null or T0.U_IMP = '')  then '0' else T0.U_IMP end )as 'InputTube',
    *(T0.U_Wieghtm * T0.BLength1)[KgLength], T0.ValidComm[-], T2.Price[PriceL],  T0.SWW[Spec],T0.U_ManStd, T0.U_MaterialSpec,T0.U_WIEGHTM[KgMetre],* 
    (T2.Price/(CASE WHEN T0.BLength1 = 0 THEN 0.0001 ELSE T0.BLength1 END))[PriceM]
    FROM OITM T0  INNER JOIN ITM1 T2 ON T0.ItemCode = T2.ItemCode,
    OCRD T3
    WHERE T3.CardName = '[%1]'
    and LEFT(T0.ITEMCODE,1)<>'L'
    and t0.itmsgrpcod <> '105'
    and t0.itmsgrpcod <> '101'
    and t0.itmsgrpcod <> '112'
    and t0.itmsgrpcod <> '113'
    and t0.itmsgrpcod <> '111'
    and t0.itmsgrpcod<>'114'
    and T2.[PriceList] = T3.[ListNum]
    and T3.CardType = 'C'        
    --order by T0.ITEMNAME
    SELECT
    ITEMINFO.SearchCode,
    --iteminfo.itemname,
    ITEMINFO.Description,
    ITEMINFO.Available,
    (case when ITEMINFO.Expected is null then '0' else ITEMINFO.Expected end ) as 'Expected',
    (case when req.forecast is null then 0 when req.forecast = 0 then 0 when req.forecast > 0 then (iteminfo.available + (case when ITEMINFO.Expected is null then 0 else ITEMINFO.Expected end)) / (case when req.FORECAST is null then 0 else req.FORECAST end)end) as 'Months Left of Stock',
    --(case when Inv.[Qty] is null then Inv.[Qty]  else Inv.[Qty] end) as 'i qty',
    --(case when Crn.[Qty] is null then Crn.[Qty]  else Crn.[Qty] end) as 'c qty',
    --(case when Inv.ItemMonths is null then Inv.ItemMonths else Inv.ItemMonths end) as 'Invoice ItemMonths',
    (case when  (Inv.[Qty] is null or Crn.[Qty] is null) and Inv.ItemMonths is null then '0' when Inv.[Qty] is null then '0' when Inv.ItemMonths ='0' then Inv.[Qty] when Crn.[Qty] is null and Inv.[Qty] >=0 then (Inv.[Qty] / Inv.ItemMonths) ELSE ((Inv.[Qty] - Crn.[Qty]) / Inv.ItemMonths) END) AS 'Garsin Avg Sales Per Month',
    (case when req.FORECAST is null then '0' else req.FORECAST end) as 'Valogix Avg Sales Per Month',
    (case when ITEMINFO.InputTube is null then '0' else ITEMINFO.InputTube end) as 'Input Tube',
    (case when ITEMINFO.KgLength is null then '0' else ITEMINFO.KgLength end) as 'Kg Length',
    (case when ITEMINFO.PriceL is null then '0' else ITEMINFO.PriceL end) as 'Price L' ,
    (case when ITEMINFO.Spec is null then '0' else ITEMINFO.Spec end) as 'Standard/Non-Standard', Iteminfo.U_MaterialSpec as 'Material Grade',
    (case when iteminfo.U_manstd is null then ' ' else iteminfo.U_manstd end) as 'Manufacturing Standard' ,
    (case when ITEMINFO.KgMetre is null then '0' else ITEMINFO.KgMetre end) as 'Kg Metre',
    (case when Iteminfo.PriceM is null then '0' else Iteminfo.PriceM end) as 'Price M'
    FROM Invoices Inv left outer JOIN Credit Crn ON Inv.[ItemCode] = Crn.[ItemCode]
                      full outer join ItemInfo  ON Inv.[ItemCode] =ItemInfo.[SearchCode]
    *                         left outer join req on req.item =  iteminfo.searchcode collate SQL_Latin1_general_CP850_CI_AS     *
    where Iteminfo.SearchCode is not null
    GROUP BY iteminfo.itemname , ItemInfo.[SearchCode], ItemInfo.[Description],Iteminfo.Available, Inv.Qty, Crn.Qty, Inv.ItemMonths, Iteminfo.Expected, ItemInfo.InputTube, ItemInfo.KgLength, Iteminfo.PriceL, ItemInfo.Spec,iteminfo.U_manstd,Iteminfo.Kgmetre, Iteminfo.U_MaterialSpec,ItemInfo.PriceM,req.FORECAST
    order by iteminfo.itemname
    end
    else
    begin
    WITH Invoices AS  --Get invoices per item
    *(SELECT T0.[ItemCode], T0.[FrgnName], SUM(I1.[Quantity]) AS Qty,*
            *DATEDIFF(month, T0.CreateDate,getdate()) AS ItemMonths*            
       *FROM OITM T0  full outer join inv1 i1 on T0.ItemCode = I1.ItemCode*
                     *left join OINV I0 ON I0.DocEntry = I1.DocEntry*
      *WHERE I0.[DocDate] >= '2006-06-01'*
        *AND I0.DocType <> 'S'*
      *GROUP BY T0.[ItemCode], T0.[FrgnName], T0.CreateDate*
    *Credit AS               -- Get credit notes per item*
    (      SELECT C1.[ItemCode],
    *                C1.[Dscription],*
    *                SUM(C1.[Quantity]) AS Qty*
    *          FROM ORIN C0  INNER JOIN RIN1 C1 ON C0.DocEntry = C1.DocEntry*
           WHERE C0.[DocDate] >= '2006-06-01'
                 AND C0.DocType <> 'S'
          GROUP BY C1.[ItemCode], C1.[Dscription]
    ItemInfo As
    (SELECT T0.ItemCode[SearchCode], t0.ItemName,T0.FRGNName[Description], cast (cast ((T0.OnHand- T0.IsCommited) as decimal (5,0)) as nvarchar (10))[Available], cast (cast (T0.OnOrder as decimal (5,0)) as nvarchar (10))[Expected],
    (case when (T0.U_IMP is null or T0.U_IMP = '')  then '0' else T0.U_IMP end )as 'InputTube',
    *(T0.U_Wieghtm * T0.BLength1)[KgLength], T0.ValidComm[-], T2.Price[PriceL],  T0.SWW[Spec], T0.U_MaterialSpec,T0.U_WIEGHTM[KgMetre],* 
    (T2.Price/(CASE WHEN T0.BLength1 = 0 THEN 0.0001 ELSE T0.BLength1 END))[PriceM]
    FROM OITM T0  INNER JOIN ITM1 T2 ON T0.ItemCode = T2.ItemCode,
    OCRD T3
    WHERE T3.CardName = '[%1]'
    and LEFT(T0.ITEMCODE,1)<>'L'
    and t0.itmsgrpcod <> '105'
    and t0.itmsgrpcod <> '101'
    and t0.itmsgrpcod <> '112'
    and t0.itmsgrpcod <> '113'
    and t0.itmsgrpcod <> '111'
    and t0.itmsgrpcod<>'114'
    and T2.[PriceList] = T3.[ListNum]
    and T3.CardType = 'C'        
    --order by T0.ITEMNAME
    SELECT
    ITEMINFO.SearchCode,
    --iteminfo.itemname,
    ITEMINFO.Description,
    ITEMINFO.Available,
    (case when ITEMINFO.Expected is null then '0' else ITEMINFO.Expected end ) as 'Expected',
    (case when ITEMINFO.InputTube is null then '0' else ITEMINFO.InputTube end) as 'Input Tube',
    (case when ITEMINFO.KgLength is null then '0' else ITEMINFO.KgLength end) as 'Kg Length',
    (case when ITEMINFO.PriceL is null then '0' else ITEMINFO.PriceL end) as 'Price L' ,
    (case when ITEMINFO.Spec is null then '0' else ITEMINFO.Spec end) as 'Standard/Non-Standard', Iteminfo.U_MaterialSpec as 'Material Spec',
    (case when ITEMINFO.KgMetre is null then '0' else ITEMINFO.KgMetre end) as 'Kg Metre',
    (case when Iteminfo.PriceM is null then '0' else Iteminfo.PriceM end) as 'Price M'
    FROM Invoices Inv left outer JOIN Credit Crn ON Inv.[ItemCode] = Crn.[ItemCode]
                      full outer join ItemInfo  ON Inv.[ItemCode] =ItemInfo.[SearchCode]
    where Iteminfo.SearchCode is not null
    GROUP BY iteminfo.itemname , ItemInfo.[SearchCode], ItemInfo.[Description],Iteminfo.Available, Inv.Qty, Crn.Qty, Inv.ItemMonths, Iteminfo.Expected, ItemInfo.InputTube, ItemInfo.KgLength, Iteminfo.PriceL, ItemInfo.Spec,Iteminfo.Kgmetre, Iteminfo.U_MaterialSpec,ItemInfo.PriceM
    order by iteminfo.itemname
    end
    >>BASICALLY THERE ARE 2 QUERIES BUILT INTO ONE. IF THE USERCODE IS 1,5,8,9,22, OR 44 THEN IT WILL EXECUTE THE FIRST PART OTHERWISE IT EXECUTES THE OTHER PART. THIS ISNT THE ISSUE WTH MY QUERY AS I HAVE CHECKED THE USERCODE.

  • Sql query not executed using recordset

    Hi All,
    I am trying to first format and then execute SQL query statement using recordset object with DI API. the issue is with vb.net's string formatting. I want to use 'USE [DB_Name]' statement in SQL and then 'Alter Procedure ..' statement. as this has to be the first statement in sql , I am using 'GO' in between and seperating each sentence with following syntax.
      Dim AltProc  as string
      AltProc = " USE [DB_name]" & Environment.NewLine
      AltProc = AltProc & " GO " &  Environment.NewLine
      AltProc = AltProc & " ALTER proc [proc_name] " &  Environment.NewLine
    '---------------------and so on
    Orec.DoQuery(AltProc)
    this formatting does not recognize new line and gives 'incorrect syntax near 'Go'' error.  strange thing is, if I take this query in SQL, it runs perfectly and I can see it getting formatted with each new line created. I tried even VbcrLf but it didnt work.
    any one has any idea?
    thanks in advance,
    Binita

    HI Binita
    The reason:
    GO is the "command" delimiter of MS Query Editor.
    It is not working with RecordSet Object.
    In MS SQL 2008 version you can define the schema before the procedure name but in SQL server 2000/2005 it is not possible.
    IN SQL 2008 use the Fully Qualified name instead of GO:
    Dim AltProc  as string
      AltProc = " ALTER proc [DB_name].[dbo].[proc_name] "  + vbcrlf
    '---------------------and so on
    Orec.DoQuery(AltProc)
    it is not working on MS SQL 2008 i have tried.
    'CREATE/ALTER PROCEDURE' does not allow specifying the database name as a prefix to the object name.'
    Regards,
    J.
    Edited by: Janos  Nagy on Jun 22, 2009 2:55 PM

  • ABAP query not executing

    Dear all,
    I have created ABAP query on purchasing. But in SQ1, when I executed " TEST", it throws message "List is wider than 255 characters (generation not possible) ". please let me know what changes I need for successful execution of query?
    thanks and regards,
    Prashanth

    Hi Prashanth,
    It seems that the output that you generate is wider than 255 char. try with lesser fields in the output and check.
    Hope it helps.
    Thanks,
    Anju

  • Query not executing any results

    Hi,
    I have created a Custom Virtual Cube with a custom function module. This Cube displays data when i check it through the transaction code - LISTCUBE.
    I have a query which has to be executed on this Virtual Cube. When i execute this Query , it does not display any data at all. It always displays "No applicable data found".
    I have tried with the combination of inputs for which the data is available in the cube. but still it gives "No applicable data found".
    Can someone suggest me what i have to do to correct this problem.
    Thanks
    Maddy

    Hi Maddy,
    I also encountered similar problem in BI 7.0, which doesn't happen in BW 3.5, though I was using Basic Cube, not Virtual Cube. I could finally work it out. Here are the steps I used:
    - Right click on the InfoCube > choose "Manage".
    - In the "Requests" tab, click the traffic light button in the "Request Status" column, set it to "Status OK".
    - The "Request for Reporting Available" column will show the "Request is available for reporting" icon automatically.
    - Try to execute your query again.
    Hope this might be relevant to your situation as well.
    Regards,
    arie

  • BIC7.0.3 Level4 BCT-CO Query not executing

    BI7.0 SP10
    BI Content 7.0.3 Level 4
    Hello All,
    I have installed the Business Content Controlling Analysis scenario.  I have loaded the master and transactional data.  I am now trying to execute business content queries (0CCA_C11_Q00XX).  When trying to execute queries for 0CCA_C11 via Query Designer (BI7.0), I am getting the following error:
    "Variable 0P_FVAEX could not be replaced"
    This error occurs after I have entered fields for the selection screen then attempted to execute the query.
    All help is appreciated!
    Thanks,
    -B

    0P_FVAEX is an SAP Exit variable for the fiscal year variant characteristic

Maybe you are looking for

  • My new rMBP 13" inch has a exclamation point on the wifi signal, even though i can browse just fine.

    Not a major issue,but still one i'd like to solve if possible Just some background on the machine, i bought it only today, though its a mid 2014 model. 2.8 GHz Intel Core i5, 512GB model. I don't know what to think, is this a software issue with Yose

  • Interactive report: How to display "count" column on total data set?

    Hi, I'm a relative newbie to APEX and would appreciate some help with the following: I have an interactive report that will usually contain around 8000 rows. I need to report the total number of distinct values in one of the columns - but I need to g

  • Links in PDF not working when viewed in browser

    Whenever I view an interactive PDF in a Firefox window the links in the PDF don't work. They work in other browsers like Chrome and Safari, but in Firefox they are as dead as normal text. It also says: "This PDF document contains forms (even though i

  • Where's "Insert Pages" in iWork's Pages 2013?

    In Pages 2009, we were able to see all of the different styles of pages by clicking on the "Pages" icon with that "+" sign at the top of the document or we could go to Insert > Pages to see the array of page style options to choose from. Has the loca

  • Generic method and wildcards

    Suppose I have this simplified code to do dynamic mapping between specific classes. My question is: the addItem and getItem functions are pretty similar however addItem compiles fine and getItem raises compilation error: Type mismatch: cannot convert