any analytic function or any other function of last time stamp?
Hello gurus,do you have an idea of the analytical function or any other function that gets me the last time stamp?
say I have data like this
login_time login_id name
2/11/2010 11:08:32 AM A123 Frank
2/11/2010 2:33:59 PM A123 fRANK
2/11/2010 6:10:45 PM A123 Frank
2/10/2010 8:12:25 AM B369 morgon
2/10/2010 6:10:27 PM B369 Morgon
so now, I want to get the latest connection time...well in frank case would be 2/11/2010 6:10:45 PM
in morgon case would be 2/10/2010 6:10:27 PM
Any idea gurus?
Analytical MAX (without band) extracted a line for each connection, add a SEPARATE for separate lines:
SELECT UPPER (name) AS u_name, MAX (login_time) over (partition by UPPER (name)) AS last_login_time
FROM table_x
ROW_NUMBER analytic to get just one line for each user:
SELECT u_name, login_time from (
SELECT UPPER (name) AS u_name, login_time, ROW_NUMBER() over (partition by UPPER (name) ORDER BY login_time desc) rn
FROM table_x
)
where rn=1
Max
http://oracleitalia.WordPress.com
Tags: Database
Similar Questions
-
Right-click the folder or any other function does not work, and I don't have a sticky key...
While I click right click in windows Explorer has stopped working... Help, please!
A Virus Scan. Your PC can be infected. If you have not installed it, use MS Security Essentials if you have a genuine Version of Windows. It's free.
-
Hello experts.
I have data similar to what follows below
create table t1 ( id number(30), description varchar(4000) ); insert into t1 values (1, 'zone'); insert into t1 values (2, 'small'); create table t2 ( id number(30), place varchar(4000), info varchar(4000) ); insert into t2 values (1, 'USA', 'Class U'); insert into t2 values (1, 'Mexico', 'Class M'); insert into t2 values (2, 'Germany', 'Class G');
I need help with something similar to what follows below without using any analytic function
Description of the ID info Place
1 box USA class U
Mexico 1 M class
2 small Germany class G
Any help is appreciated. Thank you
Hello
user13328581 wrote:
... I use an older version of oracle. Oracle 7.
Normally, your developers are older than your software.
You should be able to do what you want with a self-join on t2; a copy (d) should be displayed, and the other copy (c) contains all related values you need for comparison.
SELECT t2d.id
DECODE (t2d.place
MAX (t2c.place)
t1.description
) AS description
t2d.place
t2d.info
FROM t1
, t2 t2d - display
t2 t2c - compare
WHERE t1.id = t2d.id
AND t2d.id = t2c.id
GROUP BY t1.description
t2d.id
t2d.place
t2d.info
ORDER BY t2d.id
t2d.place DESC
;
Output:
ID DESCRIPTION PLACE INFO
---------- -------------------- -------------------- --------------------
1 box USA class U
Mexico 1 M class
2 small Germany class G
I've tested this in Oracle 11, but it should work in Oracle 7.
If this isn't the case, you may need to create a view.
-
analytical functions in oracle
Hi I am new to oracle analytical functions
I do not know how to use and where to use real-time, please send me the useful any url for it.
I read in the Oracle Documentation , but it's not understand for me.
Please provide me with any other useful URL, I'll read to those.if you have examples, please report it in the present.
Thank you
Check this box:
-
Hi gurus,
I ask someone to enlighten me on the analytical functions.
I used the following query:
The sample result set is:select * from (select filename,count(regexp_substr(filename,'.*era'))over( partition by regexp_substr(filename,'.*era') ) cnt FROM l_x12n_835_fileinfo where partitionnum=76000 and clntsysnum=76500 and radt>='01-JAN-2010') where cnt>1
Now, I changed the query to:FILENAME CNT rsmedcalwa.20100105.chpwr.072.era 4 rsmedcalwa.20100105.chpwr.072.era.1 4 rsmedcalwa.20100105.chpwr.072.era.2 4 rsmedcalwa.20100105.chpwr.072.era.3 4 rsmedcalwa.20100105.chpwr.081.era 3 rsmedcalwa.20100105.chpwr.081.era.1 3 rsmedcalwa.20100105.chpwr.081.era.2 3 rsmedcalwa.20100106.chpwr.088.era 3 rsmedcalwa.20100106.chpwr.088.era.1 3 rsmedcalwa.20100106.chpwr.088.era.2 3 rsmedcalwa.20100108.chppr.363.era.3 4 rsmedcalwa.20100108.chppr.363.era.1 4 rsmedcalwa.20100108.chppr.363.era.2 4 rsmedcalwa.20100108.chppr.363.era 4
The result set has beenselect * from (select filename,count(regexp_substr(filename,'.*era'))over( partition by regexp_substr(filename,'.*era') order by filename ) cnt FROM l_x12n_835_fileinfo where partitionnum=76000 and clntsysnum=76500 and radt>='01-JAN-2010') where cnt>1
(1) I don't understand how the addition of the order by clause changes the count. Could someone explain please?FILENAME CNT rsmedcalwa.20100105.chpwr.072.era.1 2 rsmedcalwa.20100105.chpwr.072.era.2 3 rsmedcalwa.20100105.chpwr.072.era.3 4 rsmedcalwa.20100105.chpwr.081.era.1 2 rsmedcalwa.20100105.chpwr.081.era.2 3 rsmedcalwa.20100106.chpwr.088.era.1 2 rsmedcalwa.20100106.chpwr.088.era.2 3 rsmedcalwa.20100108.chppr.363.era.1 2 rsmedcalwa.20100108.chppr.363.era.2 3 rsmedcalwa.20100108.chppr.363.era.3 4 rsmedcalwa.20100112.chpwr.175.era.1 2 rsmedcalwa.20100112.chpwr.175.era.2 3
When I change this order by order of regexp_substr(filename,'.*era'), it gives me the correct number.
My requirement is to check how many similar file names I.
(2) if there are any other better elsewhere, please let me know.Hello
Analytical functions still carried on in a window of the the result set, which can be smaller than the result set.
If you have a PARTITION BY clause, the window for each row includes rows with the same values from all the PARTITION BY expressions.
If you have an ORDER BY clause, the window includes that of a section of consecutive lines in the score, as defined by a windowing clause (in other words, LINES or KEEP them). The default value is "RANGE BETWEEN UNBOUNDED PRECEDING AND LINE CURRENT.In your case, if the analytical clause is:
over( partition by regexp_substr(filename,'.*era') )
and the line you are looking at a filename = 'rsmedcalwa.20100105.chpwr.072.era.2', the window takes up the entire partition, in other words, all lines whose name includes "rsmedcalwa.20100105.chpwr.072.era". In other words, the window is identical to the partition, because theree is no ORDER BY clause.
But if you add an ORDER BY clause:
over( partition by regexp_substr(filename,'.*era') order by filename )
then the window (potentially) decreases. Since there is no clause window, the default value 'RANGE BETWEEN UNBOUNDED PRECDING AND a CURRENT LINE' is used, which means that only the lines with a lower or equal to "rsmedcalwa.20100105.chpwr.072.era.2" file name (using the normal string comparison) will affect the results.
The analytical ORDER BY clause is required for certain features (such as ROW_NUMBER) significance only in regard to certain commands. For the most part fucntions (including COUNTY), the ORDER BY clause is optional, and you do not have to use a. In this case, it seems that you do not want the effect of a smaller than the partition window, just so, do not use an ORDER byclause of Analytics for this function.
Remember, the analytical ORDER byclause is completely independent the ORDER BY query clause. If you want the result presented in a certain order, use an ORDER BY clause at the end of the query. It will not change the results of the analytical functions.
-
Analytic function can support this requirement?
As a result of some Qry, I get the following result set. Column1 Column2 A 100 A 200 A 200 A 100 B 200 B 200 B 200 C 100 C 200 D 200 D 200 E 200 With this as input i had to take some decision like, For a particular Column1 value, if all the avaiable value of column2 is 200 (B, D & E in this case), i need to do one set of operations, if atleast one of the value for Column2 is non 200 (A & C in this case), i need to do another set of operation. How to frame the If clause or any other approach? By using Analytical count(*) function, is it possible to generate something like Column1 Column2 Column3(200_count) A 100 2 A 200 2 A 200 2 A 100 2 B 200 3 B 200 3 B 200 3 C 100 1 C 200 1 D 200 3 D 200 3 E 200 3
Jin
Something lilke this?with data as ( select 'A' column1, 100 column2 from dual union all select 'A' column1, 200 from dual union all select 'A' column1, 200 from dual union all select 'A' column1, 100 from dual union all select 'B' column1, 200 from dual union all select 'B' column1, 200 from dual union all select 'B' column1, 200 from dual union all select 'C' column1, 100 from dual union all select 'C' column1, 200 from dual union all select 'D' column1, 200 from dual union all select 'D' column1, 200 from dual union all select 'E' column1, 200 from dual ) select column1,column2,count(0) over (partition by column1,column2) cnt from data order by column1
The query above is considered the occuerence for each Column1 Column2.
If you want to count only 200 something like can help you.with data as ( select 'A' column1, 100 column2 from dual union all select 'A' column1, 200 from dual union all select 'A' column1, 200 from dual union all select 'A' column1, 100 from dual union all select 'B' column1, 200 from dual union all select 'B' column1, 200 from dual union all select 'B' column1, 200 from dual union all select 'C' column1, 100 from dual union all select 'C' column1, 200 from dual union all select 'D' column1, 200 from dual union all select 'D' column1, 200 from dual union all select 'E' column1, 200 from dual ) select column1,column2,sum( case when column2=200 then 1 else 0 end ) over (partition by column1) cnt from data order by column1
Kind regards
BobinPublished by: Buga added second query
-
I have a situation where I partitioned a Recordset. If in one partition on this recordset, the value of a field (field name registered) is '45' I need to order the result of this partition by - "outdate" desc "this provision" desc and order the other partition of desc 'key',' sequence ' desc, desc "outdate."
If the query looks like to.
Select row_number() over (partition by the order of the keys in sequence) RowNo, key, seq, status, outdate, receivedate from table1 where...
order by?
RowNo status outdate Seq key provision
1 200 0 24 9/13 / 2009 12/9/2009
2 200 1 23 9/10 / 2009 9/09/2009
3 200 2 24 9/09 / 2009 9/08/2009
1 210 0 24 9/13 / 2009 12/9/2009
2 210 1 * 45 * 9/09/2009-9/08/2009
3 210 2 24 9/10 / 2009 9/09/2009
So I need to get the query that will order the first series of partition by desc 'key',' order ' desc, desc "outdate" and the second set of partition (because the status of '45' exists in the second partition) by "outdate" desc "this provision" desc.
The output of the query should look like
RowNo status outdate Seq key provision
1 200 0 24 9/13 / 2009 12/9/2009
2 200 1 23 9/10 / 2009 9/09/2009
3 200 2 24 9/09 / 2009 9/08/2009
1 210 0 24 9/13 / 2009 12/9/2009
2 210 2 24 9/10 / 2009 9/09/2009
3 210 1 * 45 * 9/09/2009-9/08/2009
I don't know if this is possible using the analytical function.
I would appreciate if any can help me with that.
Thanks in advanceHello
Welcome to the forum!
You can use analytical functions in the ORDER BY clause.
I do not have your tables, so I'll use scott.emp to illustrate.
The following query sorts first by deptno. After this, the sort order for the departments that contain at least one seller is:
b job
(b) ename
DEPTNO = 30 is be the only Department with a seller, so it's the only sorting as shown above.
Other departments will be sorted by
(a) sal
(b) jobSELECT deptno , ename , job , sal FROM scott.emp ORDER BY deptno , CASE WHEN COUNT ( CASE WHEN job = 'SALESMAN' THEN 1 END ) OVER (PARTITION BY deptno) > 0 THEN ROW_NUMBER () OVER ( PARTITION BY deptno ORDER BY job , ename ) ELSE ROW_NUMBER () OVER ( PARTITION BY deptno ORDER BY sal , job ) END ;
Output:
. DEPTNO ENAME JOB SAL ---------- ---------- --------- ---------- 10 MILLER CLERK 1300 10 CLARK MANAGER 2450 10 KING PRESIDENT 5000 20 SMITH CLERK 800 20 ADAMS CLERK 1100 20 JONES MANAGER 2975 20 SCOTT ANALYST 3000 20 FORD ANALYST 3000 30 JAMES CLERK 950 30 BLAKE MANAGER 2850 30 ALLEN SALESMAN 1600 30 MARTIN SALESMAN 1250 30 TURNER SALESMAN 1500 30 WARD SALESMAN 1250
The small set of sample data you posted, the results you want can be achieved simply through
ORDER BY key , outdate DESC
I guess it's just a coincidence.
If you need help, post some examples of data that requires really looking at the status column to get good results. Display the data in executable form, such as CREATE TABLE and the instructions INSERT, olr, as Salim, a WITH clause. (Maybe you can simply add or change a couple of lines in the example Salim already posted data).
-
Analytic function to summarize
Hi, I have a question regarding the analytical functions.
SCENARIO OF
I have two fields: TICKET_ID and TASK_TIME
For each TICKET_ID, I have a task_time calculated as in the example:
TICKET_ID TASK_TIME
112293 25
112294 1200
112294 40
112295 40
112296 60
112297 120
112298 60
112299 60
112300 180
112301 1440
112302 4320
112303 120
112304 306
where:
IPTV_COUNT_TASKS_TIME is a function of DB
JTF_TASKS_B.Task Id is an area from runtime
: CREATION_DATE_UL is a parameter after PERIOD
As you can see the 112294 ticket I have 2 rows.
What I want to achieve is the following: I would like to have average task_time (taking into account all tickets), but I don't want to count 2 times the ticket 112294
So... What have I done?
I create another calculated field named SUM (Task_time) where the calculation is: SUM (TASK_TIME) OVER (PARTITION OF TICKET_ID)
and I got:
TICKET_ID TASK_TIME
112293 25
112294 1240
112294 1240
112295 40
112296 60
112297 120
112298 60
112299 60
112300 180
112301 1440
112302 4320
112303 120
112304 306
In other words, I need to summarize the task_time for each ticket and show the result only once for each ticket.
Where is the error? How I do change the SUM (Task_time) calculation?
Thanks in advance for any suggestion
AlexHello
You can create the package in a schema, although usually an APPS environment I would create the package in the APPS schema because then you need not to grant privileges.
Rod West
-
Report Builder 6i do not recognize the analytical functions
Hi all, in an attempt to speed up a slow query, I applied the analytical function to it. I can save the query in the generator without any problem, however, I can't create data between this request and other links. After I have comment on the analytical function, data bindings can be made. My colleague says Report Builder 6i is too old so he can recognize only the ANSI SQL syntax. Since our server DB uses Oracle 10 g 2, is there a way for the generator of reports to identify and compile syntax of Oracle 10 g?
Thank you very much.Hello
Your colleague is right. Even if the SQL query is executed by the DB server, reports must analyze the SQL query.
The SQL parser included in reports 6i-based 8.0.6
You can see this version using the report designer:
Menu: Help-> on Report Builder...
ORACLE Server Release 8.0.6.0.0
Concerning
-
Not able to install any other OS on Satellite M70
I have a Toshiba M70-181 and my friend has a series of satellite Toshiba M70-189.
(a) we both are not able to install any other OS outside one (Windows XP Home edition (German)) provided with the product. Is it not possible to install any other OS? Toshiba does not support any other OS?
(b) we got a German OS with the product. Is it possible that we can get a recovery CD English replacement for the Germany that we have. If yes how?
(c) is it possible to install Linux on the laptop 2 above?
(d) if it is not possible to install any other OS is so their a workaround so that we can install another OS?
[Edited by: admin on 12 February 06 15:33]
Hello
Normally there is no problem to install another OS. Just boot from the installation of the desired OS CD and it runs.
But getting the system to operate with all functions is not so easy, as Toshiba only supports Windows XP for the M70. If you want to use another language or XP Pro, there is no problem, because the drivers and software are almost the same.
But Linux or something else, to pick up on other places for drivers to work (if they already exist). I remember that I saw some people who got their system works with Linux on this forum.
Replace the recovery CD is unfortunately not possible. If you want XP in English, you need a full version of XP in English from Microsoft.
Good bye
-
I reinstalled the air combat Simulator 3 but he can't play. He gets at the beginning and then freezes. I've got shield deluxe antivirus 2009. He has not done this with the 2008 deluxe version of shield. Yet, I can play any other game.
Hi gullo56,
Welcome to Microsoft Answers Community Forums.
To help you better I would ask,
a. If it functioned very well under Windows 7 before?
· I suggest you to disable your firewall security software and check if you are able to play the game.
From the link below, what I discovered is Microsoft Flight Simulator 3 is not completely compatible with Windows 7, but I would suggest that you follow the steps below to help troubleshoot your problem.
1. as Microsoft Combat Flight Simulator 3 is supported by Microsoft Windows Vista to function normally, I suggest you run this program in Vista compatibility mode in Microsoft Windows 7.
For information about how to run a program in an earlier version of Windows, visit the link below,
http://Windows.Microsoft.com/en-us/Windows7/make-older-programs-run-in-this-version-of-Windows
2. you can also try to reduce the hardware acceleration and check if it solves your problem,
1. Click Start-> Control Panel-> appearance and personalization.
2. under customization, click on adjust the screen resolution.
3. in the display settings dialog box, click the Advanced Settings button.
4. in the monitor Properties dialog box, click the Troubleshooting tab.
5. click on the change settings button.
6. in the Security dialog box, click on continue.
7 move the hardware acceleration slider to none to reduce or turn off video hardware acceleration.
8. click on OK.
9. restart Windows.
Hope this information helped you.
Kind regards
Arona - Microsoft technical support engineer
--------------------------------------------------------------------------------------
Visit our Microsoft answers feedback Forum and let us know what you think.
-
Which analytical function to use?
Hi gurus,DB - Oracle 11 g 2
I followed the examples of data in the table test_a.
col1 col2 col3
----- ------- --------
x y y
p q y
a b y
p q y
t r y
p q y
The col3 column is always 'y '. But here's the data p, q, there is repeated 3 times (duplicate) and if this is the case I want to update only the first recordings like "n" col3 it is to say p, q, n. rest will be as it is.
I am able to get the row_number() for it but not able to do this.
Select col1, clo2, clo3 row_number() over (partition by col2) arrested by col1 as test_a r_num
Would it be possible directly by any analytic function?
Thank you
SID
COL4 is logical...
Something like that?
with x as)
Select col1, col2 ' x' 'y', 'y' col3 col4 1 Union double all the
Select 'p' col1, col2 'q', 'y' col3 col4 2 Union double all the
Select 'a' col1, col2 'b', 'y' col3 col4 3 of all the double union
Select 'p' col1, col2 'q', 'y' col3 col4 4 Union double all the
Select 't' col1, col2 'r', 'y' col3, col4 5 Union double all the
Select 'p' col1, col2 'q', 'y' col3 col4 6 double
)
---
Select * from)
Select x.*,
ROW_NUMBER() on rn1 (score of col1, col2, col3 col4 sort),
ROW_NUMBER() on rn2 (partition by col1, col2, col3 col4 desc sorting)
x
)
where rn1 = 1 and rn2 <> 1;
Understand the logic and simply change SELECT a query to UPDATE...
-
Truncate output of analytical function?
For example this query:
Select month, sum (tot_sales) monthly_sales,.
AVG (Sum (tot_sales)) (any order by month
between 1 above and 1 below) rolling_avg
orders
where year = 2001 and region_id = 6
Group by month;
gives me an output which includes several decimal places for the rolling_avg column.
Is there a way to truncate this? I tried to use the rounded outside the analytical function and surely enough, it didn't work. I can't think otherwise.
You can use an external selection on the result of this query
select trunc(rolling_avg) from ( rolling_avg query);
-
event.localX of a MovieClip regardless of any other DisplayObject over/under/inside
Here is an example:
var table:Table = new Table(); stage.addChild(table); //table covers the whole stage for (var i:int = 0; i<= 10; i++){ var book:Book = new Book(); book.x = Math.random() * stage.stageWidth; book.y = Math.random() * stage.stageHeight; if (Math.random() < .5){ stage.addChild(book) } else { table.addChild(book) } stage.addEventListener(MouseEvent.CLICK, clicked); //notice that the eventListener is added to the stage function clicked(event:MouseEvent){ trace(event.localX, event.localY); }
what I need here, it's the localX or locally TO THE TABLE, not another thing.
so the general question is "how to return event.localX of a certain MovieClip regardless of any other DisplayObject over/under/to inside it, without defining the mouseChildren to false (which I need to be enabled).
This question is another discussion I had on actionscript 3 - event.localX of a MovieClip regardless of any other DisplayObject over/under/inside - Stack Overflow
function clicked (event: MouseEvent) {}
var globalPt:Point = new Point (event.stageX, event.stageY);
var tablePt:Point = table.globalToLocal (globalPt);
trace (tablePt.x, tablePt.y);
}
SOLVED
-
HelloI have a doubt about this analytical function to lead,
I have this table,
create table test3 (no number, name varchar2 (30));
Insert into TEST3 (NO, NAME) values (1, 'fen');
Insert into TEST3 (NO, NAME) Values (3, 'DEN');
Insert into TEST3 (NO, NAME) values (2, 'Sun');
Insert into TEST3 (NO, NAME) values (2, 'sen');
Insert into TEST3 (NO, NAME) values (1, 'end');
COMMIT;I put like that with this request.
Select lead don't (don't) over (partition by any order of name), name of test3.NO NAME
1 fen
end
2 Sun
Sen
DENBut I need as below output, I am unable to get the third 'NO' that has a value, I get null for that, even if I partitioned
by the 'NO '.NO NAME
1 fen
end
2 Sun
Sen
3 DENPlease clear my doubt.
Thanks in advance.
Like this
Select decode (NWR, 1, no, null) no
name
de)
Select row_number() over (partition by any order by name) rno
None
name
of test3
)
Maybe you are looking for
-
Create the new profile has solved my problem of crash and I copied files and folders from my old profile to my new but I still can't have my favorites. What I am doing wrong?
-
Qosmio G35 display shuts off and won't turn back on
After sitting for some time an hour or more generally the screen shuts off and no button can't seem to get the monitor to turn back. The Qosmio G35 still works and every once in a while, the screen turns on, but I don't know why.
-
Original title: Windows Search I've never managed to get Windows Search to work in XP Service Pack 3, but the Search Wizard works fine. I tried to index the C: drive. I clicked on 'Rebuild' under Indexiing Options. The c: drive shows in Indexing O
-
Original title: error code trojandownloader:win32 / unruy.h This error code will not or is not removed by the essential update of Mircosofte. I can scan my system with Micorsoft and malware. It won't go away. It redirects my serch Google or Bing to a
-
Second monitor resolution problems
I have a Toshiba laptop (Windows Vista) and use my Samsung TV as a second monitor to play DVDs, iPlayer, etc.. Until recently it went well - when I connected the cable to my laptop, the laptop screen went black and the image appeared on television in