Select query. pls help
Hi all
i am new to abap
I have the following requirement.
kindly help me how to write the select queries to achieve it.
its urgent
pls help me
thanks in advance
In June of year 1, new budget prices must be determined for the following year (year 2). The budget prices for year 2 are calculated out of the average contract prices in the first 5 months of year 1 (January May). The average contract price will then (outside the system) be corrected with an index. To calculate new prices for Campina Netherlands, a report is needed to show all materials with current budget price, volumes and contract prices during the first five months of year 1
The purchasing assistant creates an excel file per Material type, based on the Budget pricelist out of SAP.
Purchasers check the file on:
 being correct,
 materials marked for deletion in SAP
 changes to be made in data
The new prices, calculated based ion the output of the SAP Budget pricelist, are sent to controlling in june year 1.
On the 1st of January year 2 the new budget prices are inserted in SAP as the new standard price / budget price.
the fields for display are as follows
<b>table</b> <b> field<b>[/b</b>] <b> description</b>
ekko ekorg pur org
ekpo matnr mat no
makt maktx mat des
cawn zunspsc unspsc code
mbew stprs standard price
mbew peinh price unit
mara meins base unit of measure
s012 menge purchsed amount of mat
in month 1
s012 menge purchsed amount of mat
in month 2
s012 menge purchsed amount of mat
in month 3
s012 menge purchsed amount of mat
in month 4
s012 menge purchsed amount of mat
in month 5
ekpo netpr net price on date criteria 1
ekpo peinh price unit
ekpo bprme order price unit
ekpo netpr net price on date criteria 2
ekpo peinh price unit
ekpo bprme order price unit
ekpo netpr net price on date criteria 3
ekpo peinh price unit
ekpo bprme order price unit
ekpo netpr net price on date criteria 4
ekpo peinh price unit
ekpo bprme order price unit
ekpo netpr net price on date criteria 5
ekpo peinh price unit
ekpo bprme order price unit
Hi,
DATA: begin of i_ekpo,
menge........
netpr............
date ..........
end of i_ekpo.
Select menge netpr date
from ekpo
into table i_ekpo
where ....
if sy-subrc = 0.
LOOP AT i_ekpo.
v_month = i_ekpo-date+4(2).
CASE v_month.
WHEN '01'
itab-menge1 = i_ekpo-menge.
itab-menge5 = i_ekpo-menge.
itab-netpr1 = i_ekpo-netpr.
itab-netpr5 = i_ekpo-netpr.
WHEN '02'.
itab-menge1 = i_ekpo-menge.
itab-menge5 = i_ekpo-menge.
itab-netpr1 = i_ekpo-netpr.
itab-netpr5 = i_ekpo-netpr.
WHEN '03'.
itab-menge1 = i_ekpo-menge.
itab-menge5 = i_ekpo-menge.
itab-netpr1 = i_ekpo-netpr.
itab-netpr5 = i_ekpo-netpr.
WHEN '12'.
itab-menge1 = i_ekpo-menge.
itab-menge5 = i_ekpo-menge.
itab-netpr1 = i_ekpo-netpr.
itab-netpr5 = i_ekpo-netpr.
ENDCASE.
APPEND itab.
ENDLOOP.
Please be more specific with some sample outputs how is should be.
Similar Messages
-
I have a row output like this
select * from test;
s.no C1 C2 C3
1 a1 b1 x1
2 a1 b1 x2
3 a1 b1 x3
i want the output as with the new added column as like this
s.no C1 C2 C3 C4
1 a1 b1 x1 a1
2 a1 b1 x2 b1
3 a1 b1 x3 x3
pls help me in this query its urgent for the solutionHello,
So, what is the complexity in this query? Would you like to mention from where you will get that C4 column?
-Ammad -
Hi all,
I m creating a table dynamically and after that i m inserting records in tht table dynamically..
After tht i want to fetch all the records from tht table into a cursor which is a SYS_REFCURSOR. as i have to return the data to frntend ..
But when i m opening tht cursor like
OPEN cur_GetCertDetails
FOR
SELECT TRIM(certrefno) As CertNo,
TRIM(damagedno) As Damagedno,
TRIM(personname) As Name,
TRIM(icnumber) As Icnumber,
TRIM(coursename) As CourseName,
TRIM(organiser) As Organiser,
TRIM(location) As Location,
TRIM(TO_CHAR(startdate,'DD-MON-YYYY') ||' ~ '||
TO_CHAR(enddate,'DD-MON-YYYY')) As StartEndDate
FROM ACprintInductionCert;
Its giving error as
64/5 PL/SQL: SQL Statement ignored
73/10 PL/SQL: ORA-00942: table or view does not exist
Dynamically created table name is ACprintInductionCert
Pls help me out ..
I have tried to use EXECUTE IMMEDIATE after FOR but its givin errsince your table is created dynamically, you can not
have the name hardcoded in the cursor....which is precisely the point (or one of them) I made in your Procedure Problem Urgent on this topic.
Once you start down the road of dynamic code execution it is very difficult to stop. Dynamic code has its uses but it should be very much the last resort. Dynamic code means you are literally running untested code in a production environment, and is consequently more likely to fail. Its failures are also more difficult to recover from. It also makes dependency tracking extremely difficult.
Cheers, APC -
Item on the listbox cant be selected. PLS HELP.
hello! i am a newbie to ABAP development.
I followed the listbox steps stated on the RSDEMO_DROPDOWN_LISTBOX because I want to populate my listbox (I created from the screen painter) with the data from a table. It was successful and I can see the data now. Problem is when I am selecting an item of the listbox, it wont be selected. the only thing always selected is the first item on the listbox? what is happening? I do not understand. PLS HELP.
big thanks.
TYPE-POOLS: VRM.
DATA: VALUE TYPE VRM_VALUES WITH HEADER LINE.
DATA: DD1(20).
DATA: INT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
SELECT * FROM SPFLI INTO TABLE INT_SPFLI.
START-OF-SELECTION.
SET SCREEN 100.
MODULE PBO OUTPUT.
LOOP AT INT_SPFLI.
VALUE-TEXT = INT_SPFLI-CITYFROM.
APPEND VALUE.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'DD1'
VALUES = VALUE[].
ENDMODULE.
MODULE PAI INPUT.
CASE SY-UCOMM.
WHEN 'BTNEXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.<b>THIS IS A FOLLOW UP QUESTION.</b>
I have listbox DD1 and I populated that with SPFLI-CITYFROM data. I used SELECT DISTINCT statement so that it will not repeat same entry on my list box. It was successful but then on the 2nd time and on the succeeding times you click on the listbox (trying to select other item), the listbox shows all the city entries from the SPFLI-CITYFROM. The SELECT DISTINCT takes effect only at first because as I have said on the 2nd and succeeding times you click the listbox, it will show you all entries of SPFLI-CITYFROM. why is that? i dont understand.
im sorry if i sound so dumb. im a newbie.<b> big thanks to all. </b>
TYPE-POOLS: VRM.
DATA: VALUE TYPE VRM_VALUES WITH HEADER LINE.
DATA: DD1(20).
DATA: INT_SPFLI TYPE STANDARD TABLE OF SPFLI WITH HEADER LINE.
SELECT DISTINCT CITYFROM FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE INT_SPFLI.
START-OF-SELECTION.
SET SCREEN 100.
MODULE PBO OUTPUT.
LOOP AT INT_SPFLI.
VALUE-KEY = INT_SPFLI-CITYFROM.
APPEND VALUE.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'DD1'
VALUES = VALUE[].
ENDMODULE.
MODULE PAI INPUT.
CASE SY-UCOMM.
WHEN 'BTNEXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. -
How Can i SEt Dynamic Variant For WEEK on SELECTION Screen.pls help me..
<b>Hi ALL..
Pls Help Me for this Problem..i am very confused how can i do that...plese tell me proper process..
i want set Dynamice Varient for WEEK on Selection screen..
I have ALrady SET Dynamice Varient for DATE on Selection Screen.ther isd option is D...but in case of WEEK there is a no option...
Plese help me..
thaks in advance..
pls help me..</b>Hello,
Define your select-option in TVARV (assume Z_THISWEEK). And use a program like:
DATA:
zlv_week TYPE KWEEK.
call function 'DATE_GET_WEEK'
exporting date = syst-datum
importing week = zlv_week.
SELECT SINGLE *
FROM tvarvc
WHERE name = 'Z_THISWEEK'
AND type = 'S'
AND numb = '0000'.
tvarvc-low = zlv_week.
IF syst-subrc <> 0.
tvarvc-name = 'Z_THISWEEK'.
tvarvc-type = 'S'.
tvarvc-opti = 'EQ'.
tvarvc-sign = 'I'.
tvarvc-numb = '0000'.
insert tvarvc.
ELSE.
update tvarc.
ENDIF.
Regards,
John. -
Large number of attributes reduces data display in Query (PLS HELP).
Dear Guru's
We have newly upgraded our system to 7.0, Currently i have a Query based on master data info object(0 equipment) which contain several attributes, due to huge number of attributes, i cannot see data for few attributes( Ex:-0service descrip), but data exists for these atrrib, when i check in RSA1. my client want to use heavy number of 0Euipment numbers(nearly 10000) in selection screen. thats the reason for data not to be seen.
WE are under SP 16 also(Note 562162 - Additional selection of attribute reduces query result set is allready exists), and did not found any proper note.
So guru's can any one please tell me how i can get the data in Query for these attribute by keeping the same selection option for Equipment numbers (10000).
Dude's give me some good suggestion please...client is waiting from 1 week
Thanks in adv
Dev
Edited by: Srinivas dev on Jun 10, 2008 11:52 AMDear Yogesh,
Thanks a lot dude...
I assigned points for your kindly help....
Got any idea about by initial post Large number of attributes reduces data display in Query
Thanks and Regards
Dev -
Error in Query (Pls help)
Hi friends,
When i executed one of the queries, i get this error:
Abort System error in program <b>CL_RSDM_READ_MASTER_DATA and form_sidval_direct</b>
Diagnosis
This internal error is a targeted termination since the program has an incorrect status.
Procedure
Analyse the situation and inform SAP.
I have check all my infoobjects and master data...everything is in active but still i dont understand why i get this....
please suggest how to get rid of this error? its urgent
Regards
BalajiHi balaji,
This can be program error, need to apply support package or correction,
seems no oss found for form_sidval_direct .....
perhaps it's sid error, try to analyze and repair the infoprovider where the query created on, use transaction RSRV.
hope this helps.
assign points if useful
Regards,
Archna -
Cs5 crashing whilst using selection tool - pls help
hi
does anyone who how to fix this problem when using the selection tool? Photoshop seems to crash each time i use the selection tool, even if the thing im selecting is fairly small, i have tried deleteing the ps preferences file, turned off open gl and turned off export to clipboard...
is there anything else i should be doing as this is VERY annoying and keeps losing my work! Especially on an imac as it crashes the whole computer and i have to power off and on again..
Any help would be very much appreciated...
cheers
sarahYou must have some system related problem there causing that. On mac Photoshop never crashes the Operating System on its own.
• First of all do a system update, make sure that you have updated your Operating system to its most recent version - Software Update.
• if you have already done the above - then run Onyx
http://www.apple.com/downloads/macosx/system_disk_utilities/onyx.html
everything apart from 'rebuild databases' in the automation menu
• After you have done this you may need to trash Photoshops Preferences, to start Photoshop with a clean slate.
General advice with macs is that although these days they are very reliable, its still best to do these maintenance tasks every once in a while. For tip top speed of operation as much as anything else. Unfortunately people get a little lax on these tasks, now things are so generally reliable. -
Ok heres the table I hope u can see it...
date id citypair tail delay_minutes
1/1/2007 1 BZEIAH 466 10
1/2/2007 2 BZESJO 467 16
1/3/2007 3 BZEMIA 468 22
1/4/2007 4 BZELAX 469 21
1/5/2007 5 BZEYYZ 470 10
1/6/2007 6 BZEGUA 471 5
1/7/2007 7 BZETGU 472 8
1/8/2007 8 BZELIM 473 19
1/9/2007 9 BZEJFK 474 27
1/10/2007 10 BZEBOS 475 3
I would like to get the following, to add a new column where i get these
(all the flights that have a delay>15) / (count(id))
thank you for the help.....(all the flights that have a delay>15) / (count(id))I would understand if it was for the current id on a row, but in your case, all rows will have the same value...
How I see a logic business rule :
SQL> select * from tbl_airplane;
DT ID CITY TAIL DELAY_MIN
01/01/07 1 BZEIAH 466 100
02/01/07 1 BZEIAH 466 10
01/02/07 2 BZESJO 467 16
01/03/07 3 BZEMIA 468 22
01/04/07 4 BZELAX 469 21
01/05/07 5 BZEYYZ 470 10
01/06/07 6 BZEGUA 471 5
01/07/07 7 BZETGU 472 8
01/08/07 8 BZELIM 473 19
01/09/07 9 BZEJFK 474 27
01/10/07 10 BZEBOS 475 3
11 rows selected.
SQL> select dt, id, city, tail, delay_min,
2 count(case when delay_min>15 then 1 end) over (partition by id) / count(id) over (partition by id) avg_delay
3 from tbl_airplane ;
DT ID CITY TAIL DELAY_MIN AVG_DELAY
01/01/07 1 BZEIAH 466 100 ,5
02/01/07 1 BZEIAH 466 10 ,5
01/02/07 2 BZESJO 467 16 1
01/03/07 3 BZEMIA 468 22 1
01/04/07 4 BZELAX 469 21 1
01/05/07 5 BZEYYZ 470 10 0
01/06/07 6 BZEGUA 471 5 0
01/07/07 7 BZETGU 472 8 0
01/08/07 8 BZELIM 473 19 1
01/09/07 9 BZEJFK 474 27 1
01/10/07 10 BZEBOS 475 3 0
11 rows selected.
SQL> Nicolas. -
Select Query (Grouping) - Help
Hi,
Here is the table (sample)
Table: AmountCode
Code Amount1 Amount2 Amount3 Amount4
ABC 11 23 234 124
ABC 23 567 567 556
XYZ 56 234 235 344
XYZ 55 56 789 7855
AAA 567 12 234 4367
AAA 789 98 6577 4368
BBB
I want to sum different Columns in the above table based on the Code Field (grouping). How to write this query?
If Code = ABC
Sum(Amount1) as OutAmount
Sum(Amount2) as InAmount
If Code = XYZ
Sum(Amount3) as OutAmount
Sum(Amount4) as InAmount
If Code = AAA
Sum(Amount1) as OutAmount
Sum(Amount3) as InAmount
If Code = BBB
I want to get OutAmount & InAmount from different Table.
Thanks in advancetry like this..
for Code = BBB, i wrote general summation...
accordingly you can modify this query...
with rt as
(select 'ABC' Code, 11 Amount1, 23 Amount2, 234 Amount3, 124 Amount4 from dual union all
select 'ABC', 23, 567, 567, 556 from dual union all
select 'XYZ', 56, 234, 235, 344 from dual union all
select 'XYZ', 55, 56, 789,7855 from dual union all
select 'AAA', 567, 12, 234, 4367 from dual union all
select 'AAA', 789, 98, 6577, 4368 from dual union all
select 'BBB', null,null,null,null from dual)
select code,
decode(code,'ABC',Sum(Amount1),'XYZ',Sum(Amount3),'AAA',Sum(Amount1),'BBB',(select sum(sal) from test_emp where deptno = 10),0) OutAmount,
decode(code,'ABC',Sum(Amount2),'XYZ',Sum(Amount4),'AAA',Sum(Amount3),'BBB',(select sum(sal) from test_emp where deptno = 20),0) InAmount
from rt group by code order by code;
COD OUTAMOUNT INAMOUNT
AAA 1356 6811
ABC 34 590
BBB 12786 13237
XYZ 1024 8199 [pre] -
Newbie query .Pls help!!!
Hii
All,
i have started using java very recently.Now for a forthcoming project in jsp/servlet i am trying to install necessary things.
my os :windows 2000(prof).
java :jdk1.4
servelet --jsdk2.0
tomcat :jakarta-tomcat3.2.3
Tomcat is installed by unpacking the tar file.
i have compiled normal java files and also that using servlet classes successfully.
i have set the classpath from my computer -->properties-->advancec-->environment variables as follows
classpath =C:\jdk1.4\bin;C:\jdk1.4\lib;C:\JSDK2.0\lib\jsdk.jar;C:\jdk1.4\lib\tools.jar;C:\jakarta-tomcat-3.2.3
JAVA_HOME=C:\jdk1.4
SERVLET_HOME=C:\JSDK2.0
TOMCAT_HOME=C:\jakarta-tomcat-3.2.3
NOW I AM GETTING THE FOLLOWING ERRORS IN TWO CASES :
1. when i am trying to run servletrunner i am getting the following output:
C:\JSDK2.0\bin>servletrunner
servletrunner starting with settings:
port = 8080
backlog = 50
max handlers = 100
timeout = 5000
servlet dir = .\examples
document dir = .\examples
servlet propfile = .\examples\servlet.properties
java.net.BindException: Address in use: bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at sun.servlet.http.HttpServer.run(HttpServer.java:222)
at sun.servlet.http.HttpServer.main(HttpServer.java:432)
there is no IIS running in my pc .
2) when i am trying to browse a jsp page in tomcat (even the example .jsp pages given with tomcat) ,i am getting the following errors:
Error: 500
Location: /examples/jsp/num/numguess.jsp
Internal Servlet Error:
java.lang.NoSuchMethodError: javax.servlet.ServletException.getRootCause()Ljava/lang/Throwable;
at org.apache.tomcat.context.ExceptionHandler.doService(DefaultCMSetter.java:289)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.handleError(ContextManager.java:1183)
at org.apache.tomcat.core.Handler.service(Handler.java:312)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:579)
please help me to sort out these problem .
regards
Arnabhii
in addition to what i hav written earliar ,i would like to add over here the error i am getting while executing the startup.bat file
C:\jakarta-tomcat-4.1.24-LE-jdk14\bin>startup
Using CATALINA_BASE: C:\jakarta-tomcat-4.1.24-LE-jdk14
Using CATALINA_HOME: C:\jakarta-tomcat-4.1.24-LE-jdk14
Using CATALINA_TMPDIR: C:\jakarta-tomcat-4.1.24-LE-jdk14\temp
Using JAVA_HOME: C:\jdk1.4
java.lang.NoSuchMethodError: java.util.logging.Logger.logp(Ljava/util/logging/Le
vel;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
at org.apache.commons.logging.impl.Jdk14Logger.log(Jdk14Logger.java:126)
at org.apache.commons.logging.impl.Jdk14Logger.info(Jdk14Logger.java:192
at org.apache.commons.modeler.Registry.loadRegistry(Registry.java:264)
at org.apache.catalina.mbeans.MBeanUtils.createRegistry(MBeanUtils.java:
1702)
at org.apache.catalina.mbeans.MBeanUtils.<clinit>(MBeanUtils.java:163)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.<clinit>(
GlobalResourcesLifecycleListener.java:117)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:33)
at sun.reflect.InflatableConstructorAccessorImpl.newInstance(InflatableC
onstructorAccessorImpl.java:38)
at java.lang.reflect.Constructor.newInstance(Constructor.java:273)
at java.lang.Class.newInstance0(Class.java:290)
at java.lang.Class.newInstance(Class.java:249)
at org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.j
ava:253)
at org.apache.commons.digester.Rule.begin(Rule.java:200)
at org.apache.commons.digester.Digester.startElement(Digester.java:1268)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1452)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1717)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1469)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)
at org.apache.commons.digester.Digester.parse(Digester.java:1543)
at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:30)
at sun.reflect.InflatableMethodAccessorImpl.invoke(InflatableMethodAcces
sorImpl.java:48)
at java.lang.reflect.Method.invoke(Method.java:306)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
any further suggestions upon this post will be gr8ly appreciated
regards
arnab -
Pls help me in select query......
My problem is...
I have to use a select query in such a manner that i can compare the last 8 characters or ignore the first one...Hi Aarif,
Try this :
parameters :
p_field1(30) type c.
Data :
w_string(8) type c,
w_firstchar type c,
t_itab ......,
fs_itab like line of itab.
w_string = p_field1+22(8) " passing last 8 chars into w_string
w_firstchar = p_field1+0(1).
select *
from DataTab Name
into table IntTab Name
where <field name> eq w_string
or <field name> ne w_firstchar.
If you are accepting the value from user then first pass the last 8 characters into w_string and in your select query get the fields where the value is equal to w_string. And pass the first character into another field and to ignore write NE W_FIRSTCHAR.
There can be other methods also. This is one of the ways.
Regards,
Swapna.
Edited by: NagaSwapna Thota on Jul 19, 2008 9:23 AM -
How to compare two select quieres parallelly from 2 different Dbs(pls help)
I have tried doing it from my previous question :
pls look at this link and help me with parallelly looping 2 different databases :-
http://forums.sun.com/thread.jspa?threadID=5368358&messageID=10620723#10620723
i am attaching the code i wrote to achieve it , but i know i am not right in looping : pls help me with this :-
Query ABC Oracle database with the following:
ResultSet resultSet = statement.executeQuery("select sno,Description" +
"from TableA ");
while(resultSet.next()) {
SerialCode= resultSet.getString(1);
Description= resultSet.getString(2);
newcode= Integer.parseInt(SerialCode);
// Query DEF Sybase database with the following:
ResultSet resultSet1 = statementsyb.executeQuery("select Type,Text from TableB");
while(resultSet1.next()) {
TypeCode = resultSet1.getInt(1);
TextDescription = resultSet1.getString(2);
if ((newcode == TypeCode) && (Description.equals(TextDescription))) {
}else if ((newcode == TypeCode) && (!(Description.equals(TextDescription))){
// Prepare a statement to update the record
String Sql = ("UPDATE TableB SET TextDescription = ' " + Description + " ',Abrevation = ' " + Description.substring(0,20) + "', " + .......................");
// Execute the update Statement
Count_updatedDescription_DEF = statementsyb.executeUpdate(Sql);
}else if (newcode > TypeCode) {
// Prepare a statement to insert a record
String Sql1 = ("INSERT INTO TableB(............) " +
"VALUES(...............)");
// Execute the insert statement
Count_NewType_DEF = statementsyb.executeUpdate(Sql1);
}else if (newcode < TypeCode) {
// Prepare a statement to delete a record
String Sql2 = ("DELETE from TableB where Type> '" + newcode + "'");
// Execute the delete statement
Count_DeletedType_DEF = statementsyb.executeUpdate(Sql2);
// Prepare a statement to insert a record
String Sql3 = ("INSERT INTO TableB ...........");
// Execute the insert statement
Count_NewType_DEF = statementsyb.executeUpdate(Sql3);
resultSet1.close();
resultSet.close();
{code}
pls helpPlease continue the conversation in your original thread: [http://forums.sun.com/thread.jspa?threadID=536835]
Thanks! -
Consecutive Absent Days Query.. Pls Help Gurus
I have a table which stores attendance information
For eg:
Emp_No Date
100 01-APR-2010
102 05-APR-2010
100 02-APR-2010
I need a query with parameter From Date and To date..
My Query Output should be like this .. considering that employee 100 is absent for 8 consecutive days and employee number 102 is absent for 2 consecutive days..
It should return number of consecutive days he is absent.
Empno Consecutive Days
100 8 Days
102 2 Days
Pls Help Gurus.
Edited by: suzvino on Jun 21, 2010 12:14 AMTUBBY_TUBBZ?with data as
2 (
3 select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
4 select 102 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
5 select 100 as emp_no, to_date('02-APR-2010','dd-mon-yyyy') as absent_date from dual union all
6 select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
7 select 100 as emp_no, to_date('03-APR-2010','dd-mon-yyyy') as absent_date from dual union all
8 select 100 as emp_no, to_date('04-APR-2010','dd-mon-yyyy') as absent_date from dual union all
9 select 100 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
10 select 100 as emp_no, to_date('06-APR-2010','dd-mon-yyyy') as absent_date from dual union all
11 select 100 as emp_no, to_date('07-APR-2010','dd-mon-yyyy') as absent_date from dual union all
12 select 100 as emp_no, to_date('08-APR-2010','dd-mon-yyyy') as absent_date from dual union all
13 select 100 as emp_no, to_date('09-APR-2010','dd-mon-yyyy') as absent_date from dual
14 )
15 select
16 emp_no, max(level)
17 from data
18 connect by prior emp_no = emp_no and prior absent_date = absent_date - 1
19 group by emp_no
20 having max(level) >= 8;
EMP_NO MAX(LEVEL)
100 9
1 row selected.
Elapsed: 00:00:00.01
TUBBY_TUBBZ?Think i misread the post, so the query should be
TUBBY_TUBBZ?with data as
2 (
3 select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
4 select 102 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
5 select 100 as emp_no, to_date('02-APR-2010','dd-mon-yyyy') as absent_date from dual union all
6 select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
7 select 100 as emp_no, to_date('03-APR-2010','dd-mon-yyyy') as absent_date from dual union all
8 select 100 as emp_no, to_date('04-APR-2010','dd-mon-yyyy') as absent_date from dual union all
9 select 100 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
10 select 100 as emp_no, to_date('06-APR-2010','dd-mon-yyyy') as absent_date from dual union all
11 select 100 as emp_no, to_date('07-APR-2010','dd-mon-yyyy') as absent_date from dual union all
12 select 100 as emp_no, to_date('08-APR-2010','dd-mon-yyyy') as absent_date from dual union all
13 select 100 as emp_no, to_date('09-APR-2010','dd-mon-yyyy') as absent_date from dual
14 )
15 select
16 emp_no, max(level)
17 from data
18 connect by prior emp_no = emp_no and prior absent_date = absent_date - 1
19 group by emp_no;
EMP_NO MAX(LEVEL)
100 9
102 1
2 rows selected.
Elapsed: 00:00:00.01Edited by: Tubby on May 30, 2010 11:00 PM
Added second query since i misread the post originally. -
QUERY CLARIFICATION RQD : gurus, experts pls help
Hai,
I am facing problem in performance of the query. sample scenario i have created here pls help me to solve
**VEH_MAIN* TABLE (MASTER TABLE)*
CREATE TABLE VEH_MAIN
( VIP_MOT_IND VARCHAR2(10 BYTE),
VIP_IND NUMBER(10,0)
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',1);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT02',5);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('M0T03',1);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',2);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT02',6);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',3);
Insert into VEH_MAIN (VIP_MOT_IND,VIP_IND) values ('MOT01',4);
**VEH_ENGINE_SUB* (table for engine subclass)*
CREATE TABLE VEH_ENG_SUB
( ENG_SUBCLASS VARCHAR2(50 BYTE),
ENG_MOT_IND VARCHAR2(10 BYTE)
Insert into VEH_ENG_SUB (ENG_SUBCLASS,ENG_MOT_IND) values ('ENGSUB001','MOT01');
Insert into VEH_ENG_SUB (ENG_SUBCLASS,ENG_MOT_IND) values ('ENGSUB001','MOT02');
*VEH_ENG_IND( Detail table for engine subclass)*
CREATE TABLE VEH_ENG_IND
( "ENG_SUBCLASS" VARCHAR2(50 BYTE),
"ENG_IND" VARCHAR2(10 BYTE)
Insert into VEH_ENG_IND (ENG_SUBCLASS,ENG_IND) values ('ENGSUB001','1');
Insert into VEH_ENG_IND (ENG_SUBCLASS,ENG_IND) values ('ENGSUB001','2');
*VEH_AXIS( Master table for Engine Axis)*
CREATE TABLE VEH_AXIS
( ENG_AXIS VARCHAR2(50 BYTE),
AXIS_MOT_IND VARCHAR2(10 BYTE)
Insert into VEH_AXIS (ENG_AXIS,AXIS_MOT_IND) values ('ENGAXIS001','MOT01');
Insert into VEH_AXIS (ENG_AXIS,AXIS_MOT_IND) values ('ENGAXIS002','MOT02');
*VEH_AXIS_IND( Details table for engine axis)*
CREATE TABLE VEH_AXIS_IND
( ENG_AXIS VARCHAR2(50 BYTE),
ENG_IND VARCHAR2(10 BYTE)
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','1');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','2');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','3');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS001','4');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS002','5');
Insert into VEH_AXIS_IND (ENG_AXIS,ENG_IND) values ('ENGAXIS002','6');
Condition 1
if i select only ENGINE_SUBCLASS='ENGSUB001' then
SELECT vip_mot_ind,vip_ind
FROM veh_main V,
veh_eng_sub vsub,
veh_eng_ind vind
WHERE (v.vip_mot_ind= vsub.eng_mot_ind
and v.vip_ind=vind.eng_ind
and vsub.eng_subclass= vind.eng_subclass
AND vsub.eng_subclass='ENGSUB001' )output is
MOT01 1
MOT01 2
Condition 2:if i select only the Engine Axis='ENGAXIS002' then the
SELECT vip_mot_ind,vip_ind
FROM veh_main V,
veh_axis vaxis,
veh_axis_ind vaind
WHERE v.vip_mot_ind= vaxis.axis_mot_ind
and v.vip_ind= vaind.eng_ind
and vaind.eng_axis= vaxis.eng_axis
and vaxis.eng_axis='ENGAXIS002';MOT02 5
MOT02 6
Condition 3:
BOTH ENGINE AXIS AND ENGINE SUBCLASS
SELECT vip_mot_ind,vip_ind
FROM veh_main V,
veh_eng_sub vsub,
veh_eng_ind vind,
veh_axis vaxis,
veh_axis_ind vaind
WHERE (v.vip_mot_ind= vsub.eng_mot_ind
and v.vip_ind=vind.eng_ind
and vsub.eng_subclass= vind.eng_subclass
AND vsub.eng_subclass='ENGSUB001' )
AND ( v.vip_mot_ind= vaxis.axis_mot_ind
and v.vip_ind= vaind.eng_ind
and vaind.eng_axis= vaxis.eng_axis
and vaxis.eng_axis='ENGAXIS002');Null values returned. this is correct.
But the query PERFORMANCE fails in OR CONDITON as below
Condition 4;
SELECT vip_mot_ind,vip_ind
FROM veh_main V,
veh_eng_sub vsub,
veh_eng_ind vind,
veh_axis vaxis,
veh_axis_ind vaind
WHERE (v.vip_mot_ind= vsub.eng_mot_ind
and v.vip_ind=vind.eng_ind
and vsub.eng_subclass= vind.eng_subclass
AND vsub.eng_subclass='ENGSUB001' )
OR ( v.vip_mot_ind= vaxis.axis_mot_ind
and v.vip_ind= vaind.eng_ind
and vaind.eng_axis= vaxis.eng_axis
and vaxis.eng_axis='ENGAXIS002');output
MOT02 5
MOT02 5
MOT02 5
MOT02 5
MOT02 6
MOT02 6
MOT02 6
MOT02 6
MOT01 1
MOT01 1
MOT01 1
MOT01 1
MOT01 1
MOT01 1
MOT01 1
MOT01 1
MOT01 1
MOT01 1
MOT01 1
MOT01 1
MOT01 2
MOT01 2
MOT01 2
MOT01 2
MOT01 2
MOT01 2
MOT01 2
MOT01 2
MOT01 2
MOT01 2
MOT01 2
MOT01 2
This is sample example. when i implement in huge table with partition this scennario takes much time even 2 hours to run.
i want the output must be as below if i use OR condition like condition 4
MOT01 1
MOT01 2
MOT02 5
MOT02 6
Gurus and experts pls help me to solve this problem. Dont give any suggestion like
SELECT vip_mot_ind,vip_ind
FROM veh_main V,
veh_axis vaxis,
veh_axis_ind vaind
WHERE v.vip_mot_ind= vaxis.axis_mot_ind
and v.vip_ind= vaind.eng_ind
and vaind.eng_axis= vaxis.eng_axis
and vaxis.eng_axis='ENGAXIS002'
union
SELECT vip_mot_ind,vip_ind
FROM veh_main V,
veh_eng_sub vsub,
veh_eng_ind vind
WHERE (v.vip_mot_ind= vsub.eng_mot_ind
and v.vip_ind=vind.eng_ind
and vsub.eng_subclass= vind.eng_subclass
AND vsub.eng_subclass='ENGSUB001' )
}this will give correct result...
MOT01 1
MOT01 2
MOT02 5
MOT02 6
but the problem is we cannot implement this in query. because query get framed at runtime there will be so many implement has to be done. other than UNION pls give me more suggesion
waiting..
S
Edited by: A Beginner on Sep 11, 2010 12:51 AMcreate a view v1 with all the joins
select * from v1 where eng_subclass='ENGSUB001'
union
select * from v1 where eng_axis='ENGAXIS002'
If you really do not like the direct access with union, try this
select * from v1
where vsub_PK in (select vsub_PK from v1 where eng_subclass='ENGSUB001' )
OR vsub_PK in (select vsub_PK from v1 where eng_axis='ENGAXIS002')
--vsub_PK is the primary key of table vsub
Maybe you are looking for
-
Not picking all open items at the time of out going payment(F-53)
Dear Experts, I'm facing the issue at the time of out going payment(F-53) At the time of vendor line item display system is showing open items but at the time of out going payment(F-53) system is not picking the all open items it is picking only two
-
I am on a Galaxy S4. Sending text as usually, recipient gets an email of the text. Is is my settings or theirs? What needs to be changed?
-
WPA2-Enterprise Radius Authentication Windows Server 2008 R2
Hello, I have tried a few online tutorials for providing secure wireless access. I currently have a server running Server 2008 R2 that has RRAS, NAP, and AD CS installed on it. My goal is to create a wireless SSID that utilizes WPA2-Entperise for u
-
BEFW11S4 Wireless-B Problems...Please help!
Helping my friend set up a home network. No high speed internet yet so she's just going use it for print and file sharing. Setup: Router connected via ethernet to desktop we'll call Sam office Notebook we'll call Sam notebook connected via internal w
-
CIF and representing product at vendor location in SCM
Hello All: This question is related to third-party order processing scenario in SCM that is related to Service Parts Management. For a summary of third-party order processing using GATP, please see the link below. I tested this and in order to make i