How to select date in which no transaction perform
Suppose ive a tablE T1
Dated date,
Empno varchar2(10),
status varchar2(1));
WHEN I PASS THIS QUERY
select date,empno from t1 where dated between '1-may-2007' and '30-may-2007'
it will results all the dates in which transactions are performed,and skipping the dated in which that empno is null...
my query is that query will return all the dated between passed parameter and if status is found null display 'A' .
regards
Danish Hayder
You can create a second table with any range of dates that you require and cartesian join them;
SQL> with t1 as (
select to_date('04-may-2007', 'dd-mon-yyyy') Dated, 1 Empno, 'a' status from dual union all
select to_date('06-may-2007', 'dd-mon-yyyy'), 1, 'b' from dual)
select
t2.dt,
t1.empno,
nvl(t1.status, 'a') status
from t1,
(select trunc(sysdate)-200 +rownum dt
from dual
connect by rownum <= 365) t2
where t2.dt = t1.dated(+)
and t2.dt between to_date('01-may-2007', 'dd-mon-yyyy')
and to_date('30-may-2007', 'dd-mon-yyyy')
order by t2.dt
DT EMPNO S
07-05-01 a
07-05-02 a
07-05-03 a
07-05-04 1 a
07-05-05 a
07-05-06 1 b
07-05-07 a
07-05-29 a
07-05-30 a
30 rows selected.Message was edited by:
MScallion
Forgot the NVL
Similar Messages
-
How to select data from cluster table
hi experts,
I have a report which picks data from bseg (cluster table ) for a month report it is taking around 4 minutes to process.I feel it is not good when take the report after some months.
how to select data from these table???how to declare itab for these cluster tables????can we include any search condition or any other kind of internal table???
please advice.
maniHi Manikandan,
The following code may be helpful to understand how to select the data from cluster table.
Types: Begin of ty_kna1,
Kunnr type kna1-kunnr,
adrnr type kna1-adrnr,
end of ty_kna1,
begin of ty_bseg,
belnr type bseg-belnr,
kunnr type bseg-kunnr,
end of ty_bseg,
begin of ty_final,
belnr type bseg-belnr,
kunnr type kna1-kunnr,
adrnr type kna1-adrnr,
end of ty_final.
Data: it_kna1 type table of ty_kna1,
wa_kna1 type ty_kna1,
it_bseg type table of ty_bseg,
wa_bseg type ty_bseg,
it_final type table of ty_final,
wa_final type ty_final.
Select kunnr adrnr from kna1 into table it_kna1 where....
if sy-subrc = 0.
select belnr kunnr into table it_bseg for all entries in it_kna1 where kunnr = it_kna1-kunnr.
endif.
sort it_kna1 by kunnr.
Loop at it_bseg into wa_bseg.
move wa_bseg-belnr to wa_final-belnr.
read table it_kna1 into wa_kna1 with kunnr = wa_bseg-kunnr binary search.
if sy-subrc = 0.
move: wa_kna1-kunnr to wa_final-kunnr,
wa_kna1-belnr to wa_final-belnr.
endif.
append wa_final to it_final.
clear wa_final.
endloop.
Loop at it_final into wa_final.
write: / wa_final-belnr, wa_final-kunnr, wa_final-adrnr.
endloop.
Reward if useful.
Thankyou,
Regards. -
How to select data from cube by BAPI
Hi
now i want to select data from cube by selection
and the parameter is BAPI'S import.
I want to know how can i select data from which table the storage the cube's data
Thank you for your help !!Hi,
You can use FM: RSDRI_INFOPROV_READ.
BAPI_CUBE_GETDETAIL
Pls Check the below weblog
/people/dinesh.lalchand/blog/2006/06/07/reading-infocube-data-in-updatetransfer-rules
Regards,
CSM Reddy -
How to select data from a table using a date field in the where condition?
How to select data from a table using a date field in the where condition?
For eg:
data itab like equk occurs 0 with header line.
select * from equk into table itab where werks = 'C001'
and bdatu = '31129999'.
thanks.Hi Ramesh,
Specify the date format as YYYYMMDD in where condition.
Dates are internally stored in SAP as YYYYMMDD only.
Change your date format in WHERE condition as follows.
data itab like equk occurs 0 with header line.
select * from equk into table itab where werks = 'C001'
and bdatu = <b>'99991231'.</b>
I doubt check your data base table EQUK on this date for the existince of data.
Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
data itab like equk occurs 0 with header line.
select * from equk into table itab where werks = 'C001'
and <b> bdatu <= '99991231'.</b>
Thanks,
Vinay
Thanks,
Vinay -
How to select data from a table by passing document number from another tab
How to select data from a table by passing document number from another table.
for eg:-
I want to display name, adres, region from ADRC table
by using field delivery document number
Kind Regards,
Shanbagavalli.SHi Shanbagavalli,
There are multiple solutions to this questions a few i will try to answer and then you can take the best required for your requirements.
**Consider that you have a Internal table having document number from other table..
SELECT NAME ADRES REGION FROM ADRC
INTO IT_ADRC
FOR ALL ENTRIES IN IT_DOC
WHERE DOCUMENT_NO = IT_DOC-DOCUMENT_NO.
**Consider that you have 1 document number then
SELECT NAME ADRES REGION FROM ADRC
INTO IT_ADRC
WHERE DOCUMENT_NO = W_DOCUMENT_NO.
Hope this solves your problem.
Regards,
Kunjal -
How to select data from structure
how to select data from structure
Hi Laxman,
Structure holds single record of data. You can acess data by using the syntax <b>Structure-field</b>
Please see sample.
data: wa_mara type mara.
select *
from mara
into wa_mara
up to 1 rows.
endselect.
write:/ wa_mara-mandt,
wa_mara-matnr,
wa_mara-maktl.
if helps plz reward points.
Regards
Bhupal Reddy -
How to select data from Maintance View in Program
Dear All ,
How to select data from Maintance View V_T052 in abap Program.
Regards,
ArchanaTABLES: t179, t179t.
DATA: v_t179_int TYPE TABLE OF v_t179.
SELECT * FROM t179
JOIN t179t ON
t179prodh = t179tprodh
INTO CORRESPONDING FIELDS OF TABLE v_t179_int.
Reward points... -
How to select date while Updating record
I Have created Validation through user api hook on Performance Management Module.but when user enter objective ,if is greater then or less then hundred then system raise error as per policy,but when user enter another objective to meet 100 percent then system raise error "hr object lock " because i am using select statement to sum of that object ,any body idea how to select date while inserting or updating any record.
Thansks.Hi,
drag and drop a af:convertDateTime on top of the select inputDate component
<h:form>
<af:selectInputDate label="Label 1">
<af:convertDateTime pattern="yyyy-MM-dd hh:mm"/>
</af:selectInputDate>
</h:form>
This adds the current time to the selected dat. In JDeveloper 11 you will be able to explicitly change the time in the calendar
Frank -
How to display dates on which the field of an infotype is changed
there are two fields in an infotype and both the fields are changed on different dates then how to display those dates on which the two fields are changed
Hi ankit,
If you want the change log for one infotype with one two fields, then write one custom program with following logic. If you want the log for multiple infotypes for multiple fileds then you have to use that program 'RPUAUD00'. Read the documentation of the program to check how to use it.
select * from pa0000 into table it_pa0000
where pernr = v_pernr.
sort it_pa0000 by begda descending.
loop at it_pa0000 into wa_pa0000.
write your own logic to compare the previous record PERSG with current record PERSG.
if this doesnt match then get the Changed DATE from AEDTM field.
wa_pa0000-AEDTM = changed date.
Else.
continue with loop.
exit.
endloop.
regards,
Shrinivas -
How to select data from one nested table and into another nested table
create or replace
TYPE ctxt_code_rec as object
ctxt_header varchar2(10),
header_description varchar2(300),
status varchar2(30),
adjacent_code varchar2(300),
adjacent_desc Varchar2(400),
adjacent_flag varchar2(4000),
adjacent_text_href varchar2(4000)
create or replace
type ctxt_code_table as table of CTXT_CODE_REC
d_table ctxt_code_table ;
v_tab ctxt_code_table ;
Iam trying to select data from d_table to v_tab
using and bulk collect into
select m.*
bulk collect into p_code_result
from table(l_loop_diag_code_table1)m
order by 1;
Receiving error:
ora 94007 : not enoughvalues
Could you please let me know how to solve it?
Thanks,
in advance>
create or replace
TYPE ctxt_code_rec as object
ctxt_header varchar2(10),
header_description varchar2(300),
status varchar2(30),
adjacent_code varchar2(300),
adjacent_desc Varchar2(400),
adjacent_flag varchar2(4000),
adjacent_text_href varchar2(4000)
create or replace
type ctxt_code_table as table of CTXT_CODE_REC
d_table ctxt_code_table ;
v_tab ctxt_code_table ;
Iam trying to select data from d_table to v_tab
using and bulk collect into
select m.*
bulk collect into p_code_result
from table(l_loop_diag_code_table1)m
order by 1;
Receiving error:
ora 94007 : not enoughvalues
Could you please let me know how to solve it?
>
Not unless you provide the code you are actually using.
There is no definition of 'p_code_result' in your post and you say you 'trying to select data from d_table' but there is no code that loads 'd_table' in what you posted.
And the SELECT query you posted actuall selects from an object named 'l_loop_idag_code_table1' which isn't mentioned in your code.
Post the actual code you are using and all of the structures being used.
Also explain why you even need to use nested tables and PL/SQL for whatever it is you are really doing. -
Hi,
I am writing a program which selects data from MS Excel, below is the excel sheet colums
A B C
x y z
When I run the below program i get an error for the line :
ResultSet rs = stmt.executeQuery("select B from [Sheet1$] where A=x");
Connection Failedjava.sql.SQLException: [Microsoft][ODBC Excel Driver] Too few parameters. Expected 1.
Can you please advice how to fix this code ?
package app;
import java.sql.*;
public class TestExcel {
public TestExcel() {
public static void main(String[] args) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Excel Files;DBQ=C:\\excel\\expenses1.xls; READONLY=0;", "", "");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select B from [Sheet1$] where A=x");
while (rs.next()){
String a = rs.getString(1);
System.out.println(a);
catch (Exception e) {
System.out.println("Connection Failed" + e);
ThxThat error is the driver's way of saying that you have used table names that don't exist in the database, or column names that don't exist in the table. There's only one such erroneous name in the query.
-
How to select data from struture
hello experts,
here i stuk am in smart forms where i want to populate the data from struture.
here in our comp there is no functional guy so i face bit problem to find a perticuler table but at last i found
a struture from where my problem can be resolve so can u tell me if i want to select data from struture
so how it is possible...
thanks in advance....Hi,
ST05 is the transaction used for tracing the SQL...for the particular time between Swtich on and Switch off..
If it is still difficult for you..
Then use this approach..
Go to the structure in SE12.
Then double click on the data element of the field you are looking for.
Then whereused list of the data element and search in tables..
You might get the tables that is using this data element..
Thanks,
Naren -
How to select data from an internal table
material norm date last modified
B2-SP HEAT 50.000 20090420
BF COKE 575.000 20090419
GROSS COKE 200.000 20090419
B2-SP HEAT 100.000 20090419
TWT 33.000 20090330
B7-SP HEAT 2.000 20090310
B1-SP HEAT 1.000 20090309
B7-SP HEAT 615.000 20090308
B2-SP HEAT 585.000 20090308
B1-SP HEAT 100.000 20090308
B3-SP HEAT 610.000 20090308
BF COKE 68.500 20090308
GROSS COKE 72.600 20090308
B8-SP HEAT 600.000 20090308
B9-SP HEAT 625.000 20090308
BX-SP HEAT 615.000 20090308
B9-SP HEAT 58.000 20090307
B1-SP HEAT 100.000 20090307
B6-SP HEAT 350.000 20090306
B2-SP HEAT 888.000 20090306
Like above there r numerous data in a table :
how will i select data into another internal table where material above is not repeated with latest modified date.please help.Hi Sonu,
The main task is to move the contents of the one internal table to another with some condition.
First sort and delete the duplicate entries from the First Internal table like below :
sort it_tab by material ascending date_modified descending.
delete adjacent duplicates from it_tab.
Then move that Internal table contents to another internal table.
Define another internal table with the same structure as you have first internal table and then
Second Step :
it_itab1 = it_itab.
If you are using seperate Header line and Body then you can do like below :
it_itab1[] = it_itab[].
This will fix the issue.
Please let me know if you need any further explonation.
Regards,
Kittu
Edited by: Kittu on Apr 24, 2009 12:21 PM -
How to Select data using same column name from 3 remote database
Hi,
Can anyone help me on how to get data with same column names from 3 remote database and a single alias.
Ex.
SELECT *
a.name, b.status, SUM(b.qty) qantity, MAX(b.date) date_as_of
FROM
*((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)a,*
*(table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)b)*
WHERE b.dept = 'finance'
AND a.position = 'admin'
AND a.latest = 'Y' AND (b.status <> 'TRM') AND b.qty > 0;
GROUP BY a.name, b.status ;
NOTE: the bold statements is just an example of what I want to do but I always gets an error beacause of ambiguous columns.
Thanks in advnce. :)
Edited by: user12994685 on Jan 4, 2011 9:42 PMuser12994685 wrote:
Can anyone help me on how to get data with same column names from 3 remote database and a single alias.Invalid. This does not make sense and breaks all scope resolution rules. And whether this is in a single database, or uses tables across databases, is irrelevant.
Each object must be uniquely identified. So you cannot do this:
select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a3 objects cannot share the same alias. Example:
SQL> select * from (dual, dual) d;
select * from (dual, dual) d
ERROR at line 1:
ORA-00907: missing right parenthesisYou need to combine the objects - using a join or union or similar. So it will need to be done as follows:
SQL> select * from (select * from dual d1, dual d2) d;
select * from (select * from dual d1, dual d2) d
ERROR at line 1:
ORA-00918: column ambiguously definedHowever, we need to have unique column names in a SQL projection - so the join of the tables need to project a unique set of columns. Thus:
SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
DUM DUM
X X
SQL> I suggest that you look closely at what scope is and how it applies in the SQL language - and ignore whether the objects referenced are local or remote as it has no impact to fundamentals of scope resolution. -
How to select data before a date
in previous I need to select data from invoice between date 01-10-2007 and 01-11-2007
it is work fine.
select sum(invoice_total) total from invoice
where com_id = 356
and invoice_date between TO_DATE('01-10-2007','DD-MM-YYYY') and ADD_MONTHS(TO_DATE('01-10-2007','DD-MM-YYYY'), 1)
NOW, I need to select from data invoice before 01-10-2007.
How is the statement?
Thanksplease refer to the < operator.
Sybrand Bakker
Senior Oracle DBA
Maybe you are looking for
-
Can free apps be downloaded when restrictions are on?
Can my grandson order free applications when restriction are on? I want him to be able to play but not to be able to order expensive apps (he is 6 years old).
-
Display GL Description in AP Invoice
Hi Experts Within an AP Invoice (Service) the GL Account field is obviously available but the GL Description is not and I cant see it in Form Settings. Any way to have this display the GL Description when the GL Account field is completed. Thanks! L
-
Urgent: Error during Import Metadata for IDoc
Hi We successfully imported the metadata for IDoc from R/3 in Development and Test box and everything worked fine. Now, when we try to import the metadata for IDoc in Production box it gives me an error" Basic type 'IDoc name' does not exist". I we
-
Hi, We are recycling an old system with oracle9i for as a test server for another project. How do i delete the instance from the system as we do not need it any more.
-
Is there a recommended spyware-virus scan for 10.5.5?
I'm afraid I might have a mail bug. I want to find out if thats the case. Other than installing spyware-virus scan, how could I tell, OR....is there a good program for iMacs....like MacScan? or others? Thanks