Using analytic function to get the data
Hi
Version is 11g
My table has this data
NAME SALARY LAST_UPDA
a 1000 01-JAN-07
a 2000 01-JAN-09
a 2500 01-JUN-10
b 2000 01-AUG-10
c 5000 01-JUN-07
c 6000 08-JAN-09
c 4500 01-FEB-10
I want to pick the salary and name of the person when it was last updated (max(last_update_date)).
Couple of ways of doing this I think are
SELECT distinct name,
TRUNC(
AVG(salary) KEEP (DENSE_RANK LAST
ORDER BY TO_CHAR(last_update_Date,'YYYY') )
OVER (PARTITION BY NAME)
) t
FROM kmdebug;
OR
SELECT * FROM KMDEBUG
WHERE (LAST_UPDATE_DATE, NAME) IN (SELECT MAX(LAST_UPDATE_DATE), NAME
FROM KMDEBUG
GROUP BY NAME);
They give the desired result.
NAME SALARY LAST_UPDA
a 2500 01-JUN-10
b 2000 01-AUG-10
c 4500 01-FEB-10
But the problem with the first version is DISTINCT. I want to get result set without using DISTINCT
The problem with second version is, it could be inefficient way of doing it espeically when KMDEBUG table would be big.
Thank you
MSK
A couple of thoughts.
1. 11g is not a version number.
SELECT * FROM v$version;2. Read the FAQ and learn how to use tags to format your listing so others can read it. (blue circular icon to the right)
3. Post DDL to create your table and DML to load your sample data.
Then, perhaps, someone can try your query and consider how to get you what you want.
And, when you make requests like "without using DISTINCT" you need to explain why. Because otherwise this just looks like someone trying to get us to do their homework for them.
Similar Messages
-
Using analytic function to get the right output.
Dear all;
I have the following sample date below
create table temp_one
id number(30),
placeid varchar2(400),
issuedate date,
person varchar2(400),
failures number(30),
primary key(id)
insert into temp_one values (1, 'NY', to_date('03/04/2011', 'MM/DD/YYYY'), 'John', 3);
insert into temp_one values (2, 'NY', to_date('03/03/2011', 'MM/DD/YYYY'), 'Adam', 7);
insert into temp_one values (3, 'Mexico', to_date('03/04/2011', 'MM/DD/YYYY'), 'Wendy', 3);
insert into temp_one values (4, 'Mexico', to_date('03/14/2011', 'MM/DD/YYYY'), 'Gerry', 3);
insert into temp_one values (5, 'Mexico', to_date('03/15/2011', 'MM/DD/YYYY'), 'Zick', 9);
insert into temp_one values (6, 'London', to_date('03/16/2011', 'MM/DD/YYYY'), 'Mike', 8);this is output I desire
placeid issueperiod failures
NY 02/28/2011 - 03/06/2011 10
Mexico 02/28/2011 - 03/06/2011 3
Mexico 03/14/2011 - 03/20/2011 12
London 03/14/2011 - 03/20/2011 8All help is appreciated. I will post my query as soon as I am able to think of a good logic for this...hI,
user13328581 wrote:
... Kindly note, I am still learning how to use analytic functions.That doesn't matter; analytic functions won't help in this problem. The aggregate SUM function is all you need.
But what do you need to GROUP BY? What is each row of the result set going to represent? A placeid? Yes, each row will represent only one placedid, but it's going to be divided further. You want a separate row of output for every placeid and week, so you'll want to GROUP BY placeid and week. You don't want to GROUP BY the raw issuedate; that would put March 3 and March 4 into separate groups. And you don't want to GROUP BY failures; that would mean a row with 3 failures could never be in the same group as a row with 9 failures.
This gets the output you posted from the sample data you posted:
SELECT placeid
, TO_CHAR ( TRUNC (issuedate, 'IW')
, 'MM/DD/YYYY'
) || ' - '|| TO_CHAR ( TRUNC (issuedate, 'IW') + 6
, 'MM/DD/YYY'
) AS issueperiod
, SUM (failures) AS sumfailures
FROM temp_one
GROUP BY placeid
, TRUNC (issuedate, 'IW')
;You could use a sub-query to compute TRUNC (issuedate, 'IW') once. The code would be about as complicated, efficiency probably won't improve noticeably, and the the results would be the same. -
Use SQL function to get the original order number using the invoice number
Hi All,
wondering is someone can help me with this challenge I am having? Often I need to return the original order numbers that created the resulting invoce. This is a relatively simple seriese of joins in a query but I am wanting to simplify it using a SQL function that can be referenced each time easily from with in the SELECT statement. the code i currently have is:
Use SQL function to get the original order number using the invoice number
CREATE FUNCTION dbo.fnOrdersThatMakeInvoice(@InvNum int)
RETURNS nvarchar(200)
AS
BEGIN
DECLARE @OrderList nvarchar(200)
SET @OrderList = ''
SELECT @OrderList = @OrderList + (cast(T6.DocNum AS nvarchar(10)) + ' ')
FROM OINV AS T1 INNER JOIN
INV1 AS T2 ON T1.DocEntry = T2.DocEntry INNER JOIN
DLN1 AS T4 ON T2.BaseEntry = T4.DocEntry AND T2.BaseLine = T4.LineNum INNER JOIN
RDR1 AS T5 ON T4.BaseEntry = T5.DocEntry AND T4.BaseLine = T5.LineNum INNER JOIN
ORDR AS T6 ON T5.DocEntry = T6.DocEntry
WHERE T1.DocNum = @InvNum
RETURN @OrderList
END
it is run by the following query:
Select T1.DocNum, dbo.fnOrdersThatMakeInvoice(T1.DocNum)
From OINV T1
Where T1.DocNum = 'your invoice number here'
The issue is that this returns the order number for all of the lines in the invoice. Only want to see the summary of the order numbers. ie if 3 orders were used to make a 20 line inovice I only want to see the 3 order numbers retuned in the field.
If this was a simple reporting SELECT query I would use SELECT DISTINCT. But I can't do that.
Any ideas?
Thanks,
MikeThanks Gordon,
I am trying to get away from the massive table access list everytime I write a query where I need to access the original order number of the invoice. However, I have managed to solve my own problem with a GROUP BY statement!
Others may be interested so, the code is this:
CREATE FUNCTION dbo.fnOrdersThatMakeInvoice(@InvNum int)
RETURNS nvarchar(200)
AS
BEGIN
DECLARE @OrderList nvarchar(200)
SET @OrderList = ''
SELECT @OrderList = @OrderList + (cast(T6.DocNum AS nvarchar(10)) + ' ')
FROM OINV AS T1 INNER JOIN
INV1 AS T2 ON T1.DocEntry = T2.DocEntry INNER JOIN
DLN1 AS T4 ON T2.BaseEntry = T4.DocEntry AND T2.BaseLine = T4.LineNum INNER JOIN
RDR1 AS T5 ON T4.BaseEntry = T5.DocEntry AND T4.BaseLine = T5.LineNum INNER JOIN
ORDR AS T6 ON T5.DocEntry = T6.DocEntry
WHERE T1.DocNum = @InvNum
GROUP BY T6.DocNum
RETURN @OrderList
END
and to call it use this:
Select T1.DocNum, dbo.fnOrdersThatMakeInvoice(T1.DocNum)
From OINV T1
Where T1.DocNum = 'your invoice number' -
Function to get the date after substraction
Hi Gurus,
I understand that the function "RE_ADD_MONTH_TO_DATE" is used for calculate the date after added certain month(s).
But, how do I do it in the other way. What I mean here is I want to substract the date.
For example my current date is 09.05.2008, substract 3 years is 09.05.2005.
All ideas and suggestion are greatly appreciated.
Thanks.Hi ,
u can use the same function module RE_ADD_MONTH_TO_DATE with passing months in negetive number like,
month = -36.
in the function module.
regards,
kk. -
Can I use LabVIEW to load data directly into system memory from a VI? The serial card I'm using isn't supported by NI nor does VISA recognize it. I'm using a Call Library function to read the data from the card and now I want it to go directly to system memory.
The data is being received at 1Mbps.
ThanksTwo questions:
One, if it's a serial card, then presumably it gives you more serial ports, like COM3, COM4, etc. If so, VISA would see the COM ports, and not the card directly. The drivers for the card should make it so that you see the extra serial ports from the OS. If you don't see the extra COM ports from VISA, then it sounds like the drivers for the card are not installed properly. Do the extra COM ports show up in Device Manager?
Two, you said that you're using a Call Library function to get the data and you want to put it into system memory. Errr.... you just read the data and you have it in memory by definition. Are you saying you need a way to parse the data so it shows up on a graph or something? -
Using analytical function to calculate concurrency between date range
Folks,
I'm trying to use analytical functions to come up with a query that gives me the
concurrency of jobs executing between a date range.
For example:
JOB100 - started at 9AM - stopped at 11AM
JOB200 - started at 10AM - stopped at 3PM
JOB300 - started at 12PM - stopped at 2PM
The query would tell me that JOB1 ran with a concurrency of 2 because JOB1 and JOB2
were running started and finished within the same time. JOB2 ran with the concurrency
of 3 because all jobs ran within its start and stop time. The output would look like this.
JOB START STOP CONCURRENCY
=== ==== ==== =========
100 9AM 11AM 2
200 10AM 3PM 3
300 12PM 2PM 2
I've been looking at this post, and this one if very similar...
Analytic functions using window date range
Here is the sample data..
CREATE TABLE TEST_JOB
( jobid NUMBER,
created_time DATE,
start_time DATE,
stop_time DATE
insert into TEST_JOB values (100, sysdate -1, to_date('05/04/08 09:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 11:00:00','MM/DD/YY hh24:mi:ss'));
insert into TEST_JOB values (200, sysdate -1, to_date('05/04/08 10:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 13:00:00','MM/DD/YY hh24:mi:ss'));
insert into TEST_JOB values (300, sysdate -1, to_date('05/04/08 12:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 14:00:00','MM/DD/YY hh24:mi:ss'));
select * from test_job;
JOBID|CREATED_TIME |START_TIME |STOP_TIME
----------|--------------|--------------|--------------
100|05/04/08 09:28|05/04/08 09:00|05/04/08 11:00
200|05/04/08 09:28|05/04/08 10:00|05/04/08 13:00
300|05/04/08 09:28|05/04/08 12:00|05/04/08 14:00
Any help with this query would be greatly appreciated.
thanks.
-peterafter some checking the model rule wasn't working exactly as expected.
I believe it's working right now. I'm posting a self-contained example for completeness sake.I use 2 functions to convert back and forth between epoch unix timestamps, so
I'll post them here as well.
Like I said I think this works okay, but any feedback is always appreciated.
-peter
CREATE OR REPLACE FUNCTION date_to_epoch(p_dateval IN DATE)
RETURN NUMBER
AS
BEGIN
return (p_dateval - to_date('01/01/1970','MM/DD/YYYY')) * (24 * 3600);
END;
CREATE OR REPLACE FUNCTION epoch_to_date (p_epochval IN NUMBER DEFAULT 0)
RETURN DATE
AS
BEGIN
return to_date('01/01/1970','MM/DD/YYYY') + (( p_epochval) / (24 * 3600));
END;
DROP TABLE TEST_MODEL3 purge;
CREATE TABLE TEST_MODEL3
( jobid NUMBER,
start_time NUMBER,
end_time NUMBER);
insert into TEST_MODEL3
VALUES (300,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 19:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (200,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 12:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (400,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 14:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (500,date_to_epoch(to_date('05/07/2008 11:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 16:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (600,date_to_epoch(to_date('05/07/2008 15:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 22:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (100,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 23:00','MM/DD/YYYY hh24:mi')));
commit;
SELECT jobid,
epoch_to_date(start_time)start_time,
epoch_to_date(end_time)end_time,
n concurrency
FROM TEST_MODEL3
MODEL
DIMENSION BY (start_time,end_time)
MEASURES (jobid,0 n)
(n[any,any]=
count(*)[start_time<= cv(start_time),end_time>=cv(start_time)]+
count(*)[start_time > cv(start_time) and start_time <= cv(end_time), end_time >= cv(start_time)]
ORDER BY start_time;
The results look like this:
JOBID|START_TIME|END_TIME |CONCURRENCY
----------|---------------|--------------|-------------------
100|05/07/08 09:00|05/07/08 23:00| 6
200|05/07/08 09:00|05/07/08 12:00| 5
300|05/07/08 10:00|05/07/08 19:00| 6
400|05/07/08 10:00|05/07/08 14:00| 5
500|05/07/08 11:00|05/07/08 16:00| 6
600|05/07/08 15:00|05/07/08 22:00| 4 -
Function module to get the dates from the year and the period
Is there a function Module to get the dates from the year and the period
Check with :
To get last day of period use .
LAST_DAY_IN_PERIOD_GET.
To get last of month Use :
RE_LAST_DAY_OF_MONTH
HRVE_LAST_DAY_OF_MONTH
LAST_DAY_OF_MONTHS
ISB_PREVIOUS_PERIOD_DATE_GET
Thanks
Seshu -
Date ranges - possible to use analytic functions?
The next datastructure needs to be converted to a daterange datastructure.
START_DATE END_DATE AMMOUNT
01-01-2010 28-02-2010 10
01-02-2010 31-03-2010 20
01-03-2010 31-05-2010 30
01-09-2010 31-12-2010 40Working solution:
with date_ranges
as ( select to_date('01-01-2010','dd-mm-yyyy') start_date
, to_date('28-02-2010','dd-mm-yyyy') end_date
, 10 ammount
from dual
union all
select to_date('01-02-2010','dd-mm-yyyy') start_date
, to_date('31-03-2010','dd-mm-yyyy') end_date
, 20 ammount
from dual
union all
select to_date('01-03-2010','dd-mm-yyyy') start_date
, to_date('31-05-2010','dd-mm-yyyy') end_date
, 30 ammount
from dual
union all
select to_date('01-09-2010','dd-mm-yyyy') start_date
, to_date('31-12-2010','dd-mm-yyyy') end_date
, 40 ammount
from dual
select rne.start_date
, lead (rne.start_date-1,1) over (order by rne.start_date) end_date
, ( select sum(dre2.ammount)
from date_ranges dre2
where rne.start_date >= dre2.start_date
and rne.start_date <= dre2.end_date
) range_ammount
from ( select dre.start_date
from date_ranges dre
union -- implicit distinct
select dre.end_date + 1
from date_ranges dre
) rne
order by rne.start_date
/Output:
START_DATE END_DATE RANGE_AMMOUNT
01-01-2010 31-01-2010 10
01-02-2010 28-02-2010 30
01-03-2010 31-03-2010 50
01-04-2010 31-05-2010 30
01-06-2010 31-08-2010
01-09-2010 31-12-2010 40
01-01-2011
7 rows selected.However, I would like to use an analytic function to calculate the range_ammount. Is this possible?
Edited by: user5909557 on Jul 29, 2010 6:19 AMHi,
Welcome to the forum!
Yes, you can replace the scalar sub-queriy with an analytic SUM, like this:
WITH change_data AS
SELECT start_date AS change_date
, ammount AS net_amount
FROM date_ranges
UNION
SELECT end_date + 1 AS change_date
, -ammount AS net_amount
FROM date_ranges
, got_range_amount AS
SELECT change_date AS start_date
, LEAD (change_date) OVER (ORDER BY change_date) - 1
AS end_date
, SUM (net_amount) OVER (ORDER BY change_date)
AS range_amount
FROM change_data
, got_grp AS
SELECT start_date
, end_date
, range_amount
, ROW_NUMBER () OVER ( ORDER BY start_date, end_date)
- ROW_NUMBER () OVER ( PARTITION BY range_amount
ORDER BY start_date, end_date
) AS grp
FROM got_range_amount
SELECT MIN (start_date) AS start_date
, MAX (end_date) AS end_date
, range_amount
FROM got_grp
GROUP BY grp
, range_amount
ORDER BY grp
;This should be much more efficient.
The code is longer than what you posted. That's largely because it consolidates consecutive groups with the same amount.
For example, if we add this row to the sample data:
union all
select to_date('02-01-2010','dd-mm-yyyy') start_date
, to_date('30-12-2010','dd-mm-yyyy') end_date
, 0 ammount
from dualThe query you posted produces:
START_DAT END_DATE RANGE_AMMOUNT
01-JAN-10 01-JAN-10 10
02-JAN-10 31-JAN-10 10
01-FEB-10 28-FEB-10 30
01-MAR-10 31-MAR-10 50
01-APR-10 31-MAY-10 30
01-JUN-10 31-AUG-10 0
01-SEP-10 30-DEC-10 40
31-DEC-10 31-DEC-10 40
01-JAN-11I assume you only want a new row of output when the range_amount changes., that is:
START_DAT END_DATE RANGE_AMOUNT
01-JAN-10 31-JAN-10 10
01-FEB-10 28-FEB-10 30
01-MAR-10 31-MAR-10 50
01-APR-10 31-MAY-10 30
01-JUN-10 31-AUG-10 0
01-SEP-10 31-DEC-10 40
01-JAN-11 0Of course, you could modify the original query so that it did this, but it would end up about as complex as the query above, but less efficient.
Conversely, if you prefer the longer output, then you don't need the suib-query got_grp in the query above.
Thanks for posting the CREATE TABLE and INSERT statments; that's very helpful.
There are some people who have been using this forum for years who still have to be begged to do that. -
Iam not getting the data on screen after using the user exit zxpadu01
Dear Freinds
As per my requirement when the user enters value Ansal it should get defaulted to Amount field (bet01 ) based on the wage type
i have written calculation ( q0008-bet01 = ansal/100) before it getting defaulted to bet01, i found that value is not getting default on the screen for bet01 once i enter value for Ansal , please any body correct my code
in ZXPADU02 i have written the code as below :
data : wa_p0008 like p0008,
i0008 like p0008,
l_v_ANSAL type ANSAL_15,
l_v_amount type PAD_AMT7S.
CASE innnn-infty.
when '0008'.
CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
EXPORTING
prelp = innnn
IMPORTING
pnnnn = wa_p0008. -- HERE I GOT ALL THE DATA EXCEPT BET01
if wa_p0008-lga01 = 'MFPY'.
l_v_ansal = wa_p0008-ansal.
l_v_amount = l_v_ansal / 100.
move l_v_amount to wa_p0008-bet01.
CALL METHOD cl_hr_pnnnn_type_cast=>pnnnn_to_prelp
EXPORTING
pnnnn = wa_p0008 --- HERE I CAN SEE EVEN THE BET01 IS FILLED
IMPORTING
prelp = innnn. --- HERE I CAN SEE LGART BUT NOT AMOUNT VALUE
endif.
when others.
endcase.
IN ZXPADU01 I HAVE WRITTEN AS BELOW:
data : wa_p0008 like p0008,
i0008 like p0008,
l_v_ANSAL type ANSAL_15,
l_v_amount type PAD_AMT7S.
CASE innnn-infty.
when '0008'.
MOVE-CORRESPONDING innnn to wa_p0008.
CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
EXPORTING
prelp = innnn
IMPORTING
pnnnn = wa_p0008.
if wa_p0008-lga01 = 'MFPY'.
l_v_ansal = wa_p0008-ansal.
l_v_amount = l_v_ansal / 100.
move l_v_amount to wa_p0008-bet01.
CALL METHOD cl_hr_pnnnn_type_cast=>pnnnn_to_prelp
EXPORTING
pnnnn = wa_p0008 --- I CAN SEE ONLY WHEN I COME AGAIN
IMPORTING
prelp = innnn.
endif.
when others.
endcase.
Now my problem is as follows :
i have entered the value for Ansal (ex: p0008-Ansal = 1000) ..........and i say enter then i should found the calculated value for the ansal through my coding
and it should display in bet01 as 10 ( q0008-bet01 = p0008-ansal /100)
but i dont find the value 10 being displayed for the field bet01 on the screen when
user enters Ansal as 1000 .........even then i have saved it to test the scenario......
now i came in displayed mode (pa20 ) for the infotype 008 for the same personnel no for the same dates .....where i created the record........i found that the value
bet01 is there i.e i can see the value bet01 as 10 ( my requiremnt here matching)
but when the user say enter during the time of creation of the record the value
bet01 is not getting defaulted with 10 .........why iam not able to understand
PLEASE ANY BODY HELP ME IN THIS REGARD
regards
shanti.Hi Pranesh,
i have used the logic which you hav given as below
in ZXPADU02
FIELD-SYMBOLS <fs> TYPE ANY.
ASSIGN ('(MP000800)Q0008-betrg') TO <fs>.
if <fs> is assigned.
<fs> = l_v_amount . --- amount as (ansal /100 i.e 1000/100 = 10) 10
endif.
still iam not getting the data for the field bet01
this is the coding i am using
data : wa_p0008 like p0008,
i0008 like p0008,
l_v_ANSAL type ANSAL_15,
l_v_amount type PAD_AMT7S.
FIELD-SYMBOLS <fs> TYPE ANY.
CASE innnn-infty.
when '0008'.
MOVE-CORRESPONDING innnn to wa_p0008.
CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
EXPORTING
prelp = innnn
IMPORTING
pnnnn = wa_p0008.
if wa_p0008-lga01 = 'MFPY'.
l_v_ansal = wa_p0008-ansal.
l_v_amount = l_v_ansal / 100.
move l_v_amount to wa_p0008-bet01.
ASSIGN ('(MP000800)Q0008-betrg') TO <fs>.
if <fs> is assigned.
<fs> = l_v_amount .
endif.
CALL METHOD cl_hr_pnnnn_type_cast=>pnnnn_to_prelp
EXPORTING
pnnnn = wa_p0008
IMPORTING
prelp = innnn.
endif.
when others.
endcase.
please help me as iam still not getting (value in bet 01) when i press enter once i enter value in ansal feild.
regards
shanti. -
Problem Using HTTP Dispatcher -- Could Not able to get the data in JSP
Hi, I am using HTTP Dispatcher to send my events to particular URL which is a JSP page. I am trying to populate the received event through URL and populate to a oracle data base. But could not able to get the data in Oracle database.
Code is :
<h1>JSP Page</h1>
<%
long type = 0;
String tagId = null;
String timeStr = "0";
String deviceName = "";
// Get Event Parameters
// Available Parameters: id, siteName, deviceName, data, time, type, subtype, sourceName, correlationId
try
type = Long.parseLong(request.getParameter("type")); // Get type
tagId = request.getParameter("id"); // Get tagId
timeStr = request.getParameter("time"); // Get time
deviceName = request.getParameter("deviceName");
catch (Exception e)
out.println( "Error: "+e.getMessage() );
// Write into DB.
try {
if ((tagId == null) || (type != 200) ){
// Do Nothing
//return;
} else {
OracleDataSource ods = new OracleDataSource();
String URL = "jdbc:oracle:thin:@//3.235.173.16:1525/vislocal";
ods.setURL(URL);
ods.setUser("cus");
ods.setPassword("cus");
Connection myConn = ods.getConnection();
Statement stmt = myConn.createStatement();
String selectQuery =
"SELECT MAX(rfid_raw_reads_id) as max_id FROM "+
"cus.rfid_raw_reads ";
ResultSet rs = stmt.executeQuery(selectQuery);
String maxId = "1";
if (rs.next()) {
maxId = rs.getString(1);
String selectMaxTagIDQuery =
"SELECT MAX(rfid_raw_reads_id) as max_id FROM "+
"cus.rfid_raw_reads WHERE tag_id = '" + tagId + "'" ;
stmt = myConn.createStatement();
rs = stmt.executeQuery(selectMaxTagIDQuery);
String maxTagId = "1";
if (rs.next()) {
maxTagId = rs.getString(1);
long primaryKey = 1;
long tagKey = 1;
try {
primaryKey = Long.parseLong(maxId) + 1;
tagKey = Long.parseLong(maxTagId) + 1;
} catch (Exception e) {
long currentTime = System.currentTimeMillis();
long updateKey = (tagKey - 1);
String updateQuery = " UPDATE cus.rfid_raw_reads SET read_end_time = " + currentTime + " WHERE rfid_raw_reads_id = " + updateKey;
Statement updateStmt = myConn.createStatement();
updateStmt.execute(updateQuery);
String query =
"INSERT INTO cus.rfid_raw_reads (rfid_raw_reads_id, tag_id,device_name,read_start_time) VALUES ("+ primaryKey + ",'" + tagId + "'," + deviceName + "'," + System.currentTimeMillis() + " )" ;
Statement insertStmt = myConn.createStatement();
insertStmt.execute(query);
myConn.commit();
myConn.close();
} catch (Exception e) {
%>
<p>For browser debug:
<%
out.println( "Type="+type+" ID="+tagId +" time="+timeStr );
%>
Kindly suggest where is the problem...
Thanks and regards
Mohammad Nasim AkhtarHI Prabhat,
Thanx for your reply, I worked out and able to receive the data in oracle database, Actually there was some problem in insert Query. Now I have tested the same... and able to edit the same in the Database.....
But I am facing a new problem, Http Dispatcher in SES console is displaying all the Events generated as well as event in Que but there is no events in the Event Send. I guess it is not able to send the events.....?????
Event statical is showing like this
Events Received: 0 (0.00/sec)
Events Generated: 311 (0.19/sec)
Events Sent: 2 (0.19/sec)
Queued Events: 309 (0.19/sec)
Kindly suggest where is the problem, Is it a JSP problem or OSES end problem.....
Thanks and regards
Nasim -
. wat is multiprovider wat mechanism it will use to get the data? can we c
hi gurus,
wat is multiprovider wat mechanism it will use to get the data? can we create multiprovider on one cube?wat is the advantage?
thankx in advace,
i will assign points.
srinivasHi
A MultiProvider is a type of InfoProvider that combines data from a number of InfoProviders and makes them available as a whole to reporting. The MultiProvider does not itself contain any data. Its data comes entirely from the InfoProviders on which it is based. These are combined using a union operation.
InfoProviders and MultiProviders are the objects or views that are relevant for reporting.
MultiProviders only exist as a logical definition. The data is still saved in the InfoProviders it is based on.
A query based on a MultiProvider is divided into sub-queries internally. There is a sub-query for each InfoProvider in the MultiProvider. These sub-queries are usually processed in parallel.
ADV
A MultiProvider allows reporting using several InfoProviders.
InfoCube and InfoCube: You have an InfoProvider with actual data for a logically
closed business area and an equivalent InfoProvider with plan data. You can
combine the two InfoProviders into one MultiProvider so that you can compare
the actual data with the planned data of a query.
InfoCube and InfoObject: You have an InfoCube with your products and sales.
Combine the InfoObject 0MATERIAL with it. In this way you can display the
"slow-moving items" since products that do not result in sales are also displayed.
Ya you can create multiprovider for one cube but what is need to create for single cube ?
M Kalpana -
Data Integrator has no read permissions to get the data file using FTP
Hi,
I wonder if you could help.
We have installed the data integrator and are using FTP to get the data file from the SAP server to the DI server. The files are created by the SAP admin user with permissions 660. The FTP user is not in the sapsys group so cannot read the files.
Has anyone come accross this problem and how did you solve it?
Many thanks.Hi,
you might want to put you entry into the EIM forum where also the Data Integrator topics are being handled:
Data Services and Data Quality
Ingo -
I have the original AIR recently it has really slowed down. Every function usually gets the pinwheel. It is up to date and has 10g of free disk space. Any suggestions as to the cause?
Often a failed disk or power supply. See:
https://encrypted.google.com/search?q=%22time+capsule%22+%22orange+light%22&as_q dr=all&newwindow=1&num=100 -
How can rewrite the Query using Analytical functions ?
Hi,
I have the SQL script as shown below ,
SELECT cd.cardid, cd.cardno,TT.TRANSACTIONTYPECODE,TT.TRANSACTIONTYPEDESC DESCRIPTION,
SUM (NVL (CASE tt.transactiontypecode
WHEN 'LOAD_ACH'
THEN th.transactionamount
END, 0)
) AS load_ach,
SUM
(NVL (CASE tt.transactiontypecode
WHEN 'FUND_TRANSFER_RECEIVED'
THEN th.transactionamount
END,
0
) AS Transfersin,
( SUM (NVL (CASE tt.transactiontypecode
WHEN 'FTRNS'
THEN th.transactionamount
END,
0
) +
SUM (NVL (CASE tt.transactiontypecode
WHEN 'SEND_MONEY'
THEN th.transactionamount
END, 0)
)) AS Transferout,
SUM (NVL (CASE tt.transactiontypecode
WHEN 'WITHDRAWAL_ACH'
THEN th.transactionamount
END, 0)
) AS withdrawal_ach,
SUM (NVL (CASE tt.transactiontypecode
WHEN 'WITHDRAWAL_CHECK'
THEN th.transactionamount
END, 0)
) AS withdrawal_check,
( SUM (NVL (CASE tt.transactiontypecode
WHEN 'WITHDRAWAL_CHECK_FEE'
THEN th.transactionamount
END,
0
) +
SUM (NVL (CASE tt.transactiontypecode
WHEN 'REJECTED_ACH_LOAD_FEE'
THEN th.transactionamount
END,
0
) +
SUM (NVL (CASE tt.transactiontypecode
WHEN 'WITHDRAWAL_ACH_REV'
THEN th.transactionamount
END,
0
) +
SUM (NVL (CASE tt.transactiontypecode
WHEN 'WITHDRAWAL_CHECK_REV'
THEN th.transactionamount
END,
0
) +
SUM
(NVL (CASE tt.transactiontypecode
WHEN 'WITHDRAWAL_CHECK_FEE_REV'
THEN th.transactionamount
END,
0
) +
SUM
(NVL (CASE tt.transactiontypecode
WHEN 'REJECTED_ACH_LOAD_FEE_REV'
THEN th.transactionamount
END,
0
) +
SUM (NVL (CASE tt.transactiontypecode
WHEN 'OVERDRAFT_FEE_REV'
THEN th.transactionamount
END, 0)
) +
SUM (NVL (CASE tt.transactiontypecode
WHEN 'STOP_CHECK_FEE_REV'
THEN th.transactionamount
END,
0
) +
SUM (NVL (CASE tt.transactiontypecode
WHEN 'LOAD_ACH_REV'
THEN th.transactionamount
END, 0)
) +
SUM (NVL (CASE tt.transactiontypecode
WHEN 'OVERDRAFT_FEE'
THEN th.transactionamount
END, 0)
) +
SUM (NVL (CASE tt.transactiontypecode
WHEN 'STOP_CHECK_FEE'
THEN th.transactionamount
END, 0)
)) AS Fee,
th.transactiondatetime
FROM carddetail cd,
transactionhistory th,
transactiontype tt,
(SELECT rmx_a.cardid, rmx_a.endingbalance prev_balance, rmx_a.NUMBEROFDAYS
FROM rmxactbalreport rmx_a,
(SELECT cardid, MAX (reportdate) reportdate
FROM rmxactbalreport
GROUP BY cardid) rmx_b
WHERE rmx_a.cardid = rmx_b.cardid AND rmx_a.reportdate = rmx_b.reportdate) a
WHERE th.transactiontypeid = tt.transactiontypeid
AND cd.cardid = th.cardid
AND cd.cardtype = 'P'
AND cd.cardid = a.cardid (+)
AND CD.CARDNO = '7116734387812758335'
--AND TT.TRANSACTIONTYPECODE = 'FUND_TRANSFER_RECEIVED'
GROUP BY cd.cardid, cd.cardno, numberofdays,th.transactiondatetime,tt.transactiontypecode,TT.TRANSACTIONTYPEDESC
Ouput of the above query is :
CARDID CARDNO TRANSACTIONTYPECODE DESCRIPTION LOAD_ACH TRANSFERSIN TRANSFEROUT WITHDRAWAL_ACH WITHDRAWAL_CHECK FEE TRANSACTIONDATETIME
6005 7116734387812758335 FUND_TRANSFER_RECEIVED Fund Transfer Received 0 3.75 0 0 0 0 21/09/2007 11:15:38 AM
6005 7116734387812758335 FUND_TRANSFER_RECEIVED Fund Transfer Received 0 272 0 0 0 0 05/10/2007 9:12:37 AM
6005 7116734387812758335 WITHDRAWAL_ACH Withdraw Funds via ACH 0 0 0 300 0 0 24/10/2007 3:43:54 PM
6005 7116734387812758335 SEND_MONEY Fund Transfer Sent 0 0 1 0 0 0 19/09/2007 1:17:48 PM
6005 7116734387812758335 FUND_TRANSFER_RECEIVED Fund Transfer Received 0 1 0 0 0 0 18/09/2007 7:25:23 PM
6005 7116734387812758335 LOAD_ACH Prepaid Deposit via ACH 300 0 0 0 0 0 02/10/2007 3:00:00 AM
I want the output like for Load_ACH there should be one record etc.,
Can any one help me , how can i rewrite the above query using analytical functions .,
SekharNot sure of your requirements but this mayhelp reduce your code;
<untested>
SUM (
CASE
WHEN tt.transactiontypecode IN
('WITHDRAWAL_CHECK_FEE', 'REJECTED_ACH_LOAD_FEE', 'WITHDRAWAL_ACH_REV', 'WITHDRAWAL_CHECK_REV',
'WITHDRAWAL_CHECK_FEE_REV', 'REJECTED_ACH_LOAD_FEE_REV', 'OVERDRAFT_FEE_REV','STOP_CHECK_FEE_REV',
'LOAD_ACH_REV', 'OVERDRAFT_FEE', 'STOP_CHECK_FEE')
THEN th.transactionamount
ELSE 0) feeAlso, you might want to edit your post and use [pre] and [/pre] tags around your code for formatting. -
I have tried to get the data using Win32_PnPSignedDriver but the InstallDate parameter always shows as empty when I try to retrieve it. Also, the Win32_PnPSignedDriver object does not contain all the values that could be seen when you access this window
via Device Manager.Also it looks like you're attempting scripting using WMI scripting. Perhaps you would want to download
WMI Code Creator v1.0 and read
Utility Spotlight WMI Code Creator.
WMI code creator can create code in VB Script, VB.Net and Visual C# or C#.Net I suppose.
La vida loca
Maybe you are looking for
-
If I log into MobilMe through System Preferences, I get an error stating that my password or ID is incorrect, but if I select 'Learn More' I am redirected to the MobileMe site where I can log in with my Apple ID and password. From there I can select
-
I just updated my iPad to the iOS 6. My iPad will no longer connect to the Internet.
Help! My wifi says its connecting and then immediately goes off.
-
I have a select query which uses a session variable in the where clause like so: select employee_lastname from employee where employee_id IN (#session.ids#) This runs fine if I have only 1 employee id in session.ids, but if I have multiple (i.e. 22,2
-
Hi all, I have a problem with the UWL for MDM, no records are displayed. I have configured things after all the guides and articles found here on SDN and all connection tests are fine, data is displayed in the iVews. (for Vendors). There are tasks in
-
I am on Source side and DDL replication is enabled.
I am on Source side and DDL replication is enabled. I would be providing initial dump of TABLE and VIEW objects to target using Export DP to Target. And start Golden Gate Extract, Pump on Source. Source PRM file has Table list. EXTRACT ex1test DDL IN