Sample Data Comma Query
Hi,
I have this sample data:
WITH gl_status AS
(SELECT 'EP01' status, 'This Bit' status_meaning FROM DUAL UNION ALL
SELECT 'EP02' status, 'That Bit' status_meaning FROM DUAL UNION ALL
SELECT 'EP03' status, 'Another Bit' status_meaning FROM DUAL UNION ALL
SELECT 'EM27' status, 'Green Bit' status_meaning FROM DUAL)
, tbl_data AS
(SELECT 'EP01' status FROM DUAL UNION ALL
SELECT 'EP02' FROM DUAL UNION ALL
SELECT 'EP03' FROM DUAL UNION ALL
SELECT 'EP02,EP03' FROM DUAL UNION ALL
SELECT 'EM27' FROM DUAL)
SELECT * FROM gl_status, tbl_data
WHERE tbl_data.status = gl_status.status(+)
STATUS STATUS_MEANING STATUS_1
EP01 This Bit EP01
EP02 That Bit EP02
EP03 Another Bit EP03
EM27 Green Bit EM27
EP02,EP03
5 rows selected.Where there is a match between the status columns, when the status column in the tbl_data only contains one single status value, there is no problem.
Sometimes tbl_data contains 2 values split by a comma.
I just wondered if there is any way to split that out, so I could get somehow report on the status meaning for both items?
Any advice much appreciated.
Thanks
Edited by: 966480 on Mar 26, 2013 3:51 AM
Edited by: 966480 on Mar 26, 2013 3:52 AM
for 11g:
SQL> WITH gl_status AS
2 (SELECT 'EP01' status, 'This Bit' status_meaning FROM DUAL UNION ALL
3 SELECT 'EP02' status, 'That Bit' status_meaning FROM DUAL UNION ALL
4 SELECT 'EP03' status, 'Another Bit' status_meaning FROM DUAL UNION ALL
5 SELECT 'EM27' status, 'Green Bit' status_meaning FROM DUAL)
6 , tbl_data(ID,status) AS
7 (SELECT 1,'EP01' status FROM DUAL UNION ALL
8 SELECT 2,'EP02' FROM DUAL UNION ALL
9 SELECT 3,'EP03' FROM DUAL UNION ALL
10 SELECT 4,'EP02,EP03' FROM DUAL UNION ALL
11 SELECT 5,'EM27' FROM DUAL)
12 SELECT q.id,
13 listagg(q.status,',') WITHIN GROUP (ORDER BY q.status),
14 listagg( s.status_meaning,',') WITHIN GROUP (ORDER BY q.status)
15 FROM(
16 SELECT ID,
17 REGEXP_SUBSTR(status,
18 '[^,]+',
19 1,
20 row_number() over(partition by ID order by status)) status
21 FROM tbl_data, TABLE(SELECT COLLECT(ROWNUM) FROM dual CONNECT BY INSTR(status, ',', 1, level - 1) > 0)
22 ) q
23 JOIN gl_status s
24 ON s.status = q.status
25 GROUP BY q.id
26 /
ID LISTAGG(Q.STATUS,',')WITHINGRO LISTAGG(S.STATUS_MEANING,',')W
1 EP01 This Bit
2 EP02 That Bit
3 EP03 Another Bit
4 EP02,EP03 That Bit,Another Bit
5 EM27 Green Bit
SQL> Edited by: Ramin Hashimzadeh on Mar 27, 2013 6:03 PM
Similar Messages
-
Want to select query based on sample data.
My Oracle Version
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
I am creating inventory valuation report using FIFO method . here sample data .
create table tranx(
TRXTYPE varchar2(10) ,ITEM_CODE varchar2(10), RATE number,qty number
insert into tranx values('IN' ,'14042014', 457.2 ,10);
insert into tranx values('OUT','14042014', 0, 10);
insert into tranx values('IN','14042014', 458.1, 35);
insert into tranx values('OUT','14042014', 0, 11);
insert into tranx values('OUT','14042014', 0, 6);
insert into tranx values('IN',' 14042014', 457.2 ,10);
insert into tranx values('OUT',' 14042014', 0, 3);
insert into tranx values('OUT',' 14042014', 0, 4);
insert into tranx values('IN',' 14042014', 457.2, 20);
insert into tranx values('OUT',' 14042014', 0, 5);
insert into tranx values('OUT',' 14042014', 0, 9);
insert into tranx values('OUT',' 14042014', 0, 8);
current output
TRXTYPE ITEM_CODE RATE QTY
IN 14042014 457.2 10
OUT 14042014 0 10
IN 14042014 458.1 35
OUT 14042014 0 11
OUT 14042014 0 6
IN 14042014 457.2 10
OUT 14042014 0 3
OUT 14042014 0 4
IN 14042014 457.2 20
OUT 14042014 0 5
OUT 14042014 0 9
OUT 14042014 0 8above data populate based on first in first out . but out rate is not comes from that query. suppose fist 10 qty are OUT its rate same as IN. but when qty start out from 35 rate will be 458.1 till all 35 qty will not out. like out qty 11,6,3,4,5,9 now total are 38 .
when qty 9 will out the rate are 6 qty rate 458.1 and other 3 out rate of 457.2 means total value of 9 out qty value is 4120.20 .
Now 35 qty is completed and after that rate will continue with 457.2 till 10 qty not completed.
I think you understand my detail if not please tell me .
thanks
i am waiting your reply.As SomeoneElse mentioned, there is no row order in relational tables, so you can't tell which row is first and which is next unless ORDER BY is used. So I added column SEQ to your table:
SQL> select *
2 from tranx
3 /
TRXTYPE ITEM_CODE RATE QTY SEQ
IN 14042014 457.2 10 1
OUT 14042014 0 10 2
IN 14042014 458.1 35 3
OUT 14042014 0 11 4
OUT 14042014 0 6 5
IN 14042014 457.2 10 6
OUT 14042014 0 3 7
OUT 14042014 0 4 8
IN 14042014 457.2 20 9
OUT 14042014 0 5 10
OUT 14042014 0 9 11
TRXTYPE ITEM_CODE RATE QTY SEQ
OUT 14042014 0 8 12
12 rows selected.
SQL> Now it can be solved. Your task requires either hierarchical or recursive solution. Below is recursive solution using MODEL:
with t as (
select tranx.*,
case trxtype
when 'IN' then row_number() over(partition by item_code,trxtype order by seq)
else 0
end rn_in,
case trxtype
when 'OUT' then row_number() over(partition by item_code,trxtype order by seq)
else 0
end rn_out,
count(case trxtype when 'OUT' then 1 end) over(partition by item_code) cnt_out
from tranx
select trxtype,
item_code,
rate,
qty
from t
model
partition by(item_code)
dimension by(rn_in,rn_out)
measures(trxtype,rate,qty,qty qty_remainder,cnt_out,1 current_in,seq)
rules iterate(10) until(iteration_number + 1 = cnt_out[0,1])
rate[0,iteration_number + 1] = rate[current_in[1,0],0],
qty_remainder[0,iteration_number + 1] = case sign(qty_remainder[0,cv() - 1])
when 1 then qty_remainder[0,cv() - 1] - qty[0,cv()]
else qty[current_in[1,0],0] - qty[0,cv()] + nvl(qty_remainder[0,cv() - 1],0)
end,
current_in[1,0] = case sign(qty_remainder[0,iteration_number + 1])
when 1 then current_in[1,0]
else current_in[1,0] + 1
end
order by seq
TRXTYPE ITEM_CODE RATE QTY
IN 14042014 457.2 10
OUT 14042014 457.2 10
IN 14042014 458.1 35
OUT 14042014 458.1 11
OUT 14042014 458.1 6
IN 14042014 457.2 10
OUT 14042014 458.1 3
OUT 14042014 458.1 4
IN 14042014 457.2 20
OUT 14042014 458.1 5
OUT 14042014 458.1 9
TRXTYPE ITEM_CODE RATE QTY
OUT 14042014 457.2 8
12 rows selected.
SQL> SY. -
Need help in framing an SQL query - Sample data and output required is mentioned.
Sample data :
ID Region State
1 a A1
2 b A1
3 c B1
4 d B1
Result should be :
State Region1 Region2
A1 a b
B1 c dcreate table #t (id int, region char(1),state char(2))
insert into #t values (1,'a','a1'),(2,'b','a1'),(3,'c','b1'),(4,'d','b1')
select state,
max(case when region in ('a','c') then region end) region1,
max(case when region in ('b','d') then region end) region2
from #t
group by state
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
For this sample data how to fulfill my requirement ?
For this sample data how to fulfill my requirement ?
with temp as
select 'MON' WEEKDAY,'9-10' TIMING,'I' CLASS FROM DUAL UNION
select 'MON' WEEKDAY,'9-10' TIMING,'II' CLASS FROM DUAL UNION
select 'MON' WEEKDAY,'9-10' TIMING,'III' CLASS FROM DUAL UNION
select 'MON' WEEKDAY,'10-11' TIMING,'I' CLASS FROM DUAL UNION
select 'MON' WEEKDAY,'10-11' TIMING,'II' CLASS FROM DUAL UNION
select 'TUE' WEEKDAY,'9-10' TIMING,'I' CLASS FROM DUAL UNION
select 'TUE' WEEKDAY,'9-10' TIMING,'II' CLASS FROM DUAL
select ?? (what will be the query ??)
How can i get output data in this way :
WEEKDAY TIMING CLASS
MON 9-10 I,II,III
MON 10-11 I,II
TUE 9-10 I,IIIf in 11g, you can use LISTAGG
with temp as
select 'MON' WEEKDAY,'9-10' TIMING,'I' CLASS FROM DUAL UNION
select 'MON' WEEKDAY,'9-10' TIMING,'II' CLASS FROM DUAL UNION
select 'MON' WEEKDAY,'9-10' TIMING,'III' CLASS FROM DUAL UNION
select 'MON' WEEKDAY,'10-11' TIMING,'I' CLASS FROM DUAL UNION
select 'MON' WEEKDAY,'10-11' TIMING,'II' CLASS FROM DUAL UNION
select 'TUE' WEEKDAY,'9-10' TIMING,'I' CLASS FROM DUAL UNION
select 'TUE' WEEKDAY,'9-10' TIMING,'II' CLASS FROM DUAL
select
WEEKDAY,
TIMING,
LISTAGG(CLASS,',') WITHIN GROUP (order by 1) as class_aggregate
from temp
GROUP by WEEKDAY,TIMING;
WEEKDAY TIMING CLASS_AGGREGATE
MON 9-10 I,II,III
MON 10-11 I,II
TUE 9-10 I,IIOther techniques for different versions are also mentioned here :
http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php#listagg -
I have a requirement to develop a PO/AP environment does any have sample data i can to test requisition and PO approval.
Can any send a sample PO/AP so i can with Data loaderHi VJ,
System will place a Hold only when there is mismatch between Purchase Data and Invoice data, if you get invoice details with all required details and this matches with PO ( even if the Receiving is entered in different PO line ), system will pass the Invoice.
Hope this answers your query, please let me know if you are looking for any specific information. -
hello every body
I want to start learning about data warehouse. As I understand we need to store the very large data in a database. Therefore, I am now looking for the free sample data.
1. Does anyone know where can I download the data?
2. Does Oracle provide such data?
take care
Alongkot GongmaneeHi VJ,
System will place a Hold only when there is mismatch between Purchase Data and Invoice data, if you get invoice details with all required details and this matches with PO ( even if the Receiving is entered in different PO line ), system will pass the Invoice.
Hope this answers your query, please let me know if you are looking for any specific information. -
SQL> select * from roomtype
2 ;
RT_CODE RT_DES RT_RATE
1 Single 70
2 Double 80
3 Suite 100
SQL> select * from room;
RM_NUM RM_TYPE
201 1
202 1
203 2
204 3
SQL> select * from reserve;
RES_NUM RES_ROOM RES_CHKIN RES_CHKOU RES_NAME
1001 201 01-APR-10 03-APR-10 Dobbs
1002 201 06-APR-10 08-APR-10 Black
1003 201 09-APR-10 12-APR-10 Dobbs
1004 201 16-APR-10 18-APR-10 Gregg
1005 202 02-APR-10 04-APR-10 Jones
1006 202 06-APR-10 08-APR-10 Giles
1007 202 13-APR-10 14-APR-10 Mason
1008 203 06-APR-10 11-APR-10 Ott
1009 203 12-APR-10 14-APR-10 Smith
1010 203 16-APR-10 18-APR-10 Jones
1011 204 01-APR-10 06-APR-10 Wilson
RES_NUM RES_ROOM RES_CHKIN RES_CHKOU RES_NAME
1012 204 09-APR-10 11-APR-10 Clay
1013 204 11-APR-10 18-APR-10 OlsenI need help to write a query that will list rooms that would be available for a stay with check in on 4/12 and checkout on 4/16.
I was thinking about using a subquery to find the rooms that are not available then select rooms that are not in the list of unavailable rooms returned by the subquery. What do you think and how would that look that??Hi,
What you suggested is a good way to do it if you need data from tables other than res_room. (For example, if you were only interested in Double rooms, or in a given price range).
Here's one way to do that:
SELECT rm_num
FROM room
WHERE rm_num NOT IN ( SELECT res_room
FROM reserve
WHERE res_checkin < DATE '2010-04-16'
AND res_checkout > DATE '2010-04-12'
AND res_room IS NOT NULL -- See note below
);Note: NOT IN never returns TRUE if the sub-query includes NULL. It's likely that this is impossible in your case.
If your only need data from the res_romm table (for example, just the room number) then it will usually be faster to do a query like this:
SELECT res_room
FROM reserve
GROUP BY res_room
HAVING COUNT ( CASE
WHEN res_checkin < DATE '2010-04-16'
AND res_checkout > DATE '2010-04-12'
THEN 1
END
) = 0
;If you'd like to post CREATE TABLE and INSERT statements for your sample data, then I could test this.
Hi, Warren,
Won't your query say the room is free if it has a reservation entirely within the target range?
For example, what if res_checkin is April 13, and res_checkout is April 14?
The interesting part of this question is: When do two ranges overlap?
It's actually much easier to aswer the converse question: When do two ranges NOT overlap?
They do not overlap if (and only if) one ends before the other begins.
Therefore, they do overlap if both end after the other begins. (The solution above assumes that res_checkin <= res_checkout, and that the target check-in date is less than or equal to the target check-out date.) -
Hi Experts,
A very happy new year to all of you(to some in advance)!!
I have a table where I have the employee id and task assigned with start dates & end dates. Overlapping dates of tasks is a data issue however I know how to spot them & eradicate them. So there will be no overlapping task dates
Employee_id
Task_No
Task_Start_date
Task_End_Date
Sample Data
1 T1 01-Jan-2014 28-Feb-2014
1 T2 01-Mar-2014 31-Dec-2014
2 T1 23-Jan-2014 31-Dec-2014
2 T2 01-Jan-2015 31-Dec-2073 (Means end of time)
3 T3 01-Jan-2014 15-Jul-2014
3 T4 01-Aug-2014 31-Dec-2014
4 T5 01-Jan-2014 31-Dec-2073
I want to devise a query where i provide the end date & it will list out all the employees who are free for even one day starting 01-Jan-2014. So for example If I give 31-Dec-2014, it will list out
EmpId (First day on which the employee is free)
2 01-Jan-2014
3 16-Jul-2014
If I give end date = end of time(31-Dec-2013), Expected Result -
EmpId (First day on which the employee is free)
1 01-Jan-2015
2 01-Jan-2014
3 16-Jul-2014
If I give end date = 31 Jan 2014, Expected Result -
EmpId (First day on which the employee is free)
1 01-Jan-2015
I devised following query, however it does not catch employee id 2. Also it does not provide flexibility to change end date-
select *
from (select employee_id,
task_start_date,
task_end_date,
lag(task_end_date, 1, task_start_date) over(partition by employee_id order by task_start_date) prev_end_date
from shop.employee_tasks
where task_end_date >= trunc(sysdate))
where task_start_date - prev_end_date > 1
Thanks in advance!!
Regards,This is an example of what I call the "free time" query: you have the dates when you are busy and you want the dates when you are free.
You can find a beautiful solution to the basic problem here: Ask Tom "SQL Query to find gaps in date ranges" (search for Antony Boucher's solution). Please note that this solution works even with overlapping date ranges.
To apply the solution here, first create the test data (please do this yourself in later questions).
create table t(Employee_id, task_no, Task_Start_date, task_end_date)
as select
1, 'T1', to_date('01-jan-2014'), to_date('28-feb-2014') from dual union all select
1, 'T2', to_date('01-Mar-2014'), to_date('31-Dec-2014') from dual union all select
2, 'T1', to_date('23-jan-2014'), to_date('31-dec-2014') from dual union all select
2, 'T2', to_date('01-jan-2015'), to_date('31-dec-2073') from dual union all select
3, 'T3', to_date('01-jan-2014'), to_date('15-jul-2014') from dual union all select
3, 'T4', to_date('01-aug-2014'), to_date('31-dec-2014') from dual union all select
4, 'T5', to_date('01-Jan-2014'), to_date('31-Dec-2073') from dual;
In the query, you have to add records for yesterday and for the "end date" you want. This allows you to find "free time" before and after the date ranges in your table.
Now you partition by Employee_id and order by Task_Start_date. Using the max(task_end_date) analytic function, you get the latest end date up to now. Add 1 to this and you get the first free date (maybe). To make sure that date is free, it has to be before the next start date.
variable end_date varchar2(64)
exec :end_date := '31-Dec-2073';
with boundaries as (
select trunc(sysdate)-1 task_start_date, trunc(sysdate)-1 task_end_date from dual
union all
select to_date(:end_date)+1, to_date(:end_date)+1 from dual
), data as (
select * from t
where task_end_date >= trunc(sysdate)
and task_start_date < :end_date
union all
select distinct a.employee_id, null, b.task_start_date, b.task_end_date
from t a, boundaries b
select employee_id, min(free_start) free_start
from (
select employee_id,
max(task_end_date) over (partition by employee_id order by task_start_date)+1 free_start,
lead(task_start_date) over (partition by employee_id order by task_start_date)-1 free_end
from data
where free_start <= free_end
group by employee_id;
EMPLOYEE_ID
FREE_START
1
01-JAN-15
2
01-JAN-14
3
16-JUL-14 -
Need suggestions on date range query
I have a requirement to show the amount of product remaining. There is a table that holds updated "inventory" amounts with a date and tonnage, and a series of transactional tables that detail the individual disbursements from the stockpile. The trick is that the dates for the inventory adjustments may not all be the same, meaning that I need to individually resolve the stockpiles.
This query will give me the inventory disbursements:
select FN_STN_KEY(j.FACTORY_ID, j.STATION_ID) as STATION,
count(j.LOAD_JOB_ID) as LOADS,
CASE SUM(w.SPOT_WEIGHT)
WHEN 0 THEN SUM(NVL(j.MAN_SPOT_WT,0))
ELSE SUM(w.SPOT_WEIGHT)
END TONS
from TC c, TC_LOAD_JOBS j, SPOT_WEIGHTS w
where c.TC_ID = j.TC_ID
and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
and c.DATE_INDEX BETWEEN to_date('09/01/2009','MM/DD/YYYY') and sysdate
and FN_STN_KEY(j.FACTORY_ID, j.STATION_ID) in (810,410)
group by FN_STN_KEY(j.FACTORY_ID, j.STATION_ID);Note that the date and the list of stations in the where clause are dynamic and selected by user. If this was only one station at a time it wouldn't be this complicated.
This query will give me the last known inventory amount:
select to_char(MAX(AS_OF_DT),'Mon DD, YYYY'), TONS
from STATION_LOG
where AS_OF_DT < sysdate and STN_KEY in (810,410) group by TONS;Again, the date and list of stations are selected by user. They should be identical to those selected for the other query.
Does anyone have any good ideas on how to combine these two statements into a single report?
Note: FN_STN_KEY acts as a join function. You don't really want me to get into why there isn't a single unique key to reference.Hi,
I'm trying to follow your descrioption, but lots of things don't make sense to me.
blarman74 wrote:
Yeah. I put in some data so I could get the message back to you, then filled in the rest.
So the user is going to pass in two parameters: The date of the report and the list of stations they want to get an inventory count on. What were the parameters that produced the output you posted before:
STATION INITIAL_TONS USED_TONS AS_OF_DATE
810 835500 465100 09/01/2010
410 495800 366900 09/02/2010
550 568900 122600 08/31/2010
What I need the report to do is
1) take a station from the list
2) find out the inventory tally from STATION_LOG where the date is the largest date less than the supplied date. This should give me AS_OF_DATE and my initial quantity.
3) query the data table for all tons hauled from the AS_OF_DATE for that station.
4) repeat for the next station.So this is what your existing PL/SQL code does. A non procedural language, like SQL, won't follow the same steps, of course.
The sample data for station_log is:
INSERT INTO STATION_LOG (1, to_date('08/31/2010','MM/DD/YYYY'), 810, 562500);
INSERT INTO STATION_LOG (2, to_date('09/02/2010','MM/DD/YYYY'), 410, 495500);
INSERT INTO STATION_LOG (3, to_date('09/01/2010','MM/DD/YYYY'), 910, 832600);
INSERT INTO STATION_LOG (4, to_date('12/31/2010','MM/DD/YYYY'), 810, 239800);How do you get the initial_tons in the output above from the data above? Did you mean to post some new sample data for station_log?
I still get ORA-00928 errors from all the INPUT statements.
As I said, I can do it inside a loop in PL/SQL, but I got completely stumped on how I could accomplish this in SQL. The trick is that if I can do it in SQL, I can allow the user to export the data to csv using built-in functionality. If I have to do it in PL/SQL, I can't provide the export as easily.
One more thing I just thought about, I am going to need to use a BETWEEN on the dates of the data I need to grab. I obviously don't want to grab data past another inventory tally record from STATION_LOG for the same station, and I can use an NVL so it cuts off at SYSDATE. I obviously haven't hauled anything in the future ;)I doubt if I'll get enough information to do this for you before I leave on vacation.
Here's an example of what you need to do using the scott.emp table instead of your station_log table:
SELECT job
, hiredate
, sal
FROM scott.emp
ORDER BY job
, hiredate
JOB HIREDATE SAL
ANALYST 03-Dec-1981 3000
ANALYST 19-Apr-1987 3000
CLERK 17-Dec-1980 800
CLERK 03-Dec-1981 950
CLERK 23-Jan-1982 1300
CLERK 23-May-1987 1100
MANAGER 02-Apr-1981 2975
MANAGER 01-May-1981 2850
MANAGER 09-Jun-1981 2450
PRESIDENT 17-Nov-1981 5000
SALESMAN 20-Feb-1981 1600
SALESMAN 22-Feb-1981 1250
SALESMAN 08-Sep-1981 1500
SALESMAN 28-Sep-1981 1250Say we want to find, for each job in a given list, the sal that corresponds to the last hiredate that is no later than the given report_date. (This seems pretty close to what you heed: fior each stn_key in a given list, the quantity that corresponds to the last row that is no later than the given report_date.)
That is, if we're only interested in the jobs CLERK, MANAGER and PRESIDENT, and only in hiredates on or before December 31, 1981, the output would be:
JOB LAST_HIREDA LAST_SAL
CLERK 03-Dec-1981 950
MANAGER 09-Jun-1981 2450
PRESIDENT 17-Nov-1981 5000That is, we want to ignore all jobs that are not in the given list, and all rows whose hiredate is after the given report_date. Among the rows that remain, we're interested only in the last one for each job.
Note that the last_sal for CLERK is not 1300 or 1100: those values were after the given report_date. also, the last_sal for CLERK is not 800; that's not the last one of the remaining rows.
Here's one way to get those results in pure SQL:
DEFINE jobs_wanted = "CLERK,MANAGER,PRESIDENT"
DEFINE report_date = "DATE '1981-12-31'"
SELECT job
, MAX (hiredate) AS last_hiredate
, MAX (sal) KEEP (DENSE_RANK LAST ORDER BY hiredate) AS last_sal
FROM scott.emp
WHERE hiredate <= &report_date
AND ',' || '&jobs_wanted' || ',' LIKE
'%,' || job || ',%'
GROUP BY job
ORDER BY job
;I used substitution variables for the parameters. You could use bind_variables, or hard-code the values instead.
The WHERE clause is applied before aggreate functions are computed, so rows after &report_date don't matter.
"MAX (sal) KEEP (DENSE_RANK LAST ORDER BY hiredate)" means the sal that is associated with the last row, in order by hiredate. If there happens to be a tie (that is, two or more rows have exactly the same hiredate, and no row is later) then the highest sal from thsoe rows is returned; that's what MAX means here. Ties may be impossible in your data.
You need to write a similar query using your station_log table, and join the results of that to your load_data table, including only the rows that have dates between the date in the sub-query (last_hiredate in my example) and the parameter report_date. That can be part of the join condition. -
How to avoid duplicate data while inserting from sample.dat file to table
Hi Guys,
We have issue with duplicate data in flat file while loading data from sample.dat file to table. How to avoid duplicate data in control file.
Can any one help me on this.
Thanks in advance!
Regards,
LKRNo, a control file will not remove duplicate data.
You would be better to use an external table and then remove duplicate data using SQL as you query the data to insert it to your destination table. -
Not able to access data in Query
Hi,
I have loaded data using DTP from 2 different source systems.
One is 3.x emulated datasource and the other is New 7.0 datasource.I have loaded data sucessfully in to DSO.Built a query on same.
But when iam executing the query by material as selection criteria.Iam not able to found data in query from one source system.The same data is available in DSO.Please needed in this regard.Hi Venkat,
After extracting data into DSO check the request whether active or not.
Check data in DSO in contents.
If is there any restrictions on info providers in Queries.
Let us know status clearly.......
Reg
Pra -
Time doesn't match sampled data?
Hallo all experts,
I write a LV code which reads data from USB 6211 and saves them with time instants in a text file, but the time instants don't correspond the sampled data. The time values are generated by elapsed time, after build array with the data read from DAQ, they are fed to the write to a text file. The test signal is 10 Hz, but the text file yields 0.2 Hz signal. How could I synchronize them?
Any tips are highly appreciated.
win2Don't use the "elapsed time" express VI for precision timings. It seems to have limited resolution (internally, it converts a timestamp to DBL).
You can use e.g. the tick count to keep track of the time. See the attached comparison. (still there will always be some subtle differences due to the software timings).
LabVIEW Champion . Do more with less code and in less time .
Attachments:
usb6211_forumMOD.vi 42 KB -
How Can I use a Variable in Data Controls query. Frank Kindly check...
Hii,
I am using JDeveloper 11g ADF BC.
My Requirement is that I hv a login screen which is taken from [http://blogs.oracle.com/shay/simpleJSFDBlogin.zip].
I hv attached BC in this application. I want to use the login usercode in the next pages after login screen. Next screen contains 3 list items which will be populating based on the user. So I created <af:selectOneChoice> using the BC( Just drag & dropped the column into the page from the data controls). But in the data control i want to use this usercode for passing the condition. Now Data is coming without any condition.
So How can I use the usercode in the Data controls query.
When I tried to display the usercode in the next page it is showing by binding the value. its code is follows
<af:outputText value="#{backing_getUser.uid}"
The program for checking the username & Password is follows.
package login.backing;
import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.layout.RichPanelFormLayout;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;
import java.sql.*;
import java.util.List;
import java.util.Map;
import oracle.adf.view.rich.component.rich.output.RichMessage;
import oracle.jdbc.OracleDriver;
public class GetUser {
private RichInputText uid;
private RichInputText pid;
private RichCommandButton commandButton1;
private RichInputText inputText1;
private RichInputText inputText2;
public void setUid(RichInputText inputText1) {
this.uid = inputText1;
public void setPid(RichInputText inputText2) {
this.pid = inputText2;
public RichInputText getUid() {
return uid;
public RichInputText getPid() {
return pid;
public void setCommandButton1(RichCommandButton commandButton1) {
this.commandButton1 = commandButton1;
public RichCommandButton getCommandButton1() {
return commandButton1;
public String login_action() {
// Add event code here...
String user = this.getUid().getValue().toString();
// String pass = inputText2.getValue().toString();
String pid = this.getPid().getValue().toString();
Connection conn;
conn = getConnection();
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery ("SELECT usercode FROM guser where usercode = '"+user.toUpperCase()+"' and pwd=F_TEST('"+pid.toUpperCase()+"')");
if (rset.next()) {
conn.close();
return "good";
conn.close();
} catch (SQLException e) {
System.out.println(e);
return "bad";
public static Connection getConnection() throws SQLException {
String username = "ACCTS";
String password = "ACCTS";
String thinConn = "jdbc:oracle:thin:@SERVER1:1521:G5PS";
DriverManager.registerDriver(new OracleDriver());
Connection conn =
DriverManager.getConnection(thinConn, username, password);
conn.setAutoCommit(false);
return conn;
public void setInputText1(RichInputText inputText1) {
this.inputText1 = inputText1;
public RichInputText getInputText1() {
return inputText1;
public void setInputText2(RichInputText inputText2) {
this.inputText2 = inputText2;
public RichInputText getInputText2() {
return inputText2;
-----Hi,
I didn't look at the example, but if you want to secure your application then you should use container managed security. Read this .
Anyway, you could add this before return "good"; in your login_action()
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("username", user);Then, you can access this from anywhere in the application by using #{sessionScope.username}.
Pedja -
Error in saving large value with the data input query
Hi,
I am trying to save a large value in 0Quantity using the data input query into a realtime infocube
e-g
123456789.1234
Error says too many digits.
When i try to save 8 digits before the decimal point ,no error, if it is 9digits before decimal it's thro' error.
Is there any limitation before the decimal.
i know that 0Quantity can take 17 digits including the sign.
Any suggestions.?
regards,
ramtry budgetting in thousands in stead of units? (setting on query itself)
D -
How to renormalize number of flows in Netflow Sampled data
Hi,
I am working on extrapolation(renormalization) of bytes/packets/flows from randomly sampled (1 out of N packets) collected data. I believe bytes/packets can be renormalized by multiplying bytes/packets value in exported flow record by N.
Now, I am trying to extrapolate number of flows. So far i have not got any information on it. Do you people have any idea on how flows can be renormalized from sampled data ?
Well, at the same time i have some doubts regarding this concept altogether -
1. In packet sampling, we do not know how many flows got dropped. Even router cache will not have entries for dropped flows
2. In flow sampling, router cache will maintain entries of all the flows and there may be some way by which one can know how many actual flows were there. But again there is no way to know values of individual attributes in missed flows like srcip/dstip/srcport/dstport etc.(though they are there in flow cache)
3. In case of sampling (1 out of N packets), we anyway multiply #packets and #bytes with N to arrive at estimate for total packets and bytes. When we multiply by N, it means we have taken into account all those packets as well which were NOT sampled. So, it means all the packets which flowed between source and destination have been accounted for. Then there are no missed flows, isn't it ? And if there do exist some missed flows then multiplication by N to extrapolate number of packets/bytes is not correct.
4. What is the use of count of flows anyways. Number of flows may vary depending upon the configuration such as active timeout etc. So, it does not provide any information about the actual flow between source and destination unlike number of packets and bytes.
Please share your thoughts.
Thanks,
DeepakThe simplest way is to call GetTableCellRangeValues with VAL_ENTIRE_TABLE as the range, next summing array elements.
But I don't understand your comment on checksum, so this may not be the more correct method for your actual needs: can you explain what do you mean?
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos?
Maybe you are looking for
-
How to set custom shortcuts for Styles in Pages 5.1?
I just updated Pages to version 5.1. It said, that it will bring back the feature where you can use different shortcuts for specific styles. How can you do that? Anyone figured it out yet? Thanks, Mark
-
Nokia Lumia 920 Freezing Up!
Upgraded my iPhone 4 for this Nokia 920 on 5-10-13 and was beginning to enjoy until 5-13-13 when it froze up on me. I was playing music at the time through the Xbox program. I had turned down the music level to 00 and when I was ready to increase the
-
End User Data Monitoring?
A number of our users are exceeding their monthly data allotments. One user for instance is already at 18gig for this month alone. Many of the users are unaware of what might be causing this ridiculiusly high usage (for instance they aren't using str
-
After Effects crashes instantly after start up
Whenever I run After Effects CC, an error message comes up instantly after I started it up. This is the message: Problem signature: Problem Event Name: APPCRASH Application Name: AfterFX.exe Application Version: 13.1.1.3 Application Timestamp
-
I'm un acceptable think while travelling by bus or bike music player has been stopped 5 to 7seconds when hearing an headset...please how to fix it ...this issue. Solved! Go to Solution.