Cfloop query and last row
Hello everyone,
I was trying looping over a query which has to be executed
only when the last row of a previous loop has been reached. The
question is: I have nested loops, I am able to print the values
based on two loops:
for example: <cfloop query="advisor">
<cfloop students>
</cfloop>
</cfloop>
I am able to get student values for a particular advisor and
print the values for different advisor and students. I am trying to
include another loop like grades within advisor loop which should
be executed at the end of students list for that particular
advisor. What I am doingg right now is displaying the values in a
table format.
<table>
<tr>Advisor</tr>
<tr>Student1<tr>
<tr>Student2</tr>
<tr>Grades</tr>
How is possible to know when I would reach the end of the
student loop for an advisor and then loop the grades for the same
advisor before proceeding to another advisor?
Any suggestions would be great.
Thanks.
The group attribute of cfoutput would be a lot more
efficient. Useage is described in the cfml reference manual. If you
don't have one, the internet does.
It would also be more efficient to get all your data with a
single query.
Similar Messages
-
Last execution query and last user
Hello,
I'd like to know last execution time of a query and last user - table RSZCOMPDIR provides the "Owner" and "Last changed by" only.
I don't want to install the technical content.
Have you any idea, which table contains this information (BW 3.1 used)?
Besides, Can I have same information about a query executed by WebTemplate (therefor via WEB)?
Regards,
ClaudiaHi,
You can find this information in RSDDSTAT_OLAP table.
Enter the query's technical name in OBJNAME field and a date in CALDAY one. It will be returned a list of all users (UNAME field) that executed the query in that day (sort the list by UTIME field to get to know who was the last user).
The logs in this table are generated regardless the way through which the queries are executed - WAD, Analyser etc.
Regards,
Tiago
Edited by: Tiago Santos on Feb 8, 2010 2:00 PM -
DataGrid - Query´s Last Row as Footer
Hi!
I have a query like:
SELECT [User], 'Qtd' = Count(DISTINCT [OrderId])
FROM [Jobs]
GROUP BY [User]
UNION
SELECT 'Total', 'Qtd' = Count(DISTINCT [OrderId])
FROM [Jobs];
And I´m displaying this query result in a DataGrid object in an ASPX page.
I´d like to set the last row of the query as a footer with a specific formatting. How do I set the last row of my query as a footer record at the DataGrid?
Thanks,
Molina.Hello,
Please ask your question over in the ASPNET forum
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. -
Using different hierarchy in a query and last value error
Hi guys,
there is a hierarchy for customers in the 0Customer Infoobject which I should use in my query.
I have activated the hierarchy in the query and now some results are not appearing but red crosses "x" are shown.
And the error message: The function Calculate Results as ... could not be applied everywhere.
I know that I am using the result as "last value" for some columns because I need them there (for example: to determine the last value for the credit limit of the current month). I think these columns where I am using the last value calculation are only affected.
I mean my query has a lot of characteristics and key figures and I was told that a hiearchy for customers which is available should be used. But now there are these red crosses.
I don´t see any other solution as not to use this specific hierarchy.
Has anybody a suggestion what could be an argument to use or not to use a hierarchy?
Is it sometimes like in my case that a hierarchy is not possible to use?
Thanks in advance!Hi,
say for example your customer hierarchy is customers grouped under region. You can maintain this region as one of the attribute of customer and you can display this attribute in the report. Indirectly, this will give similar output to that of hierarchy.
But lot depends on how your hierarchy is formed, before commenting whether it can be moved to master data attributes.
Thanks. -
Data query and insert rows performance
We are currently getting a system developed in Unix/Weblogic/Tomcat/Oracle environment. We have developed a screen that contains 5 or 6 different parameters to select from. We could select multiple parameters in each of these selections. The idea behind the subsequent screens is to attach information to already existing data/ possible future data that matches the selection criteria.
Based on these selections, existing data located within the system in a table is searched and those that match are selected. Also new rows are created in the table against combinations that do not currently have a match. Frequently multiple parameters are selected, and 2000 different combinations need to be searched in the table. Of these selections, only about 100 or 200 combinations will be available in existing data. So the system is having to insert 1800 rows. The user meanwhile waits for the system to come up with data based on their selections. The user is not willing to wait more than 30 seconds to get to the next screen. In the above mentioned scenario, the system takes more than an hour to insert the new records and bring the information up. We need suggestions to see if the performance can be improved this drastically. If not what are the alternatives? ThanksAre the tables have latest statsitics?
Take the statspack report and pay attention to the top 5 timed events. I would suggest you to get the session waits during this scinario.
Other workaround would be to trace the session with 10046, format with tkprof and analyze the explain plan of the queries.
Jaffar -
How to get the first and last record
Hai All
I have table called T1 and there are more than 8 lakhs records and i have a column called Timestamp so i need to get the first record value and time stampvalue and last record and time stamp value so that i can conclude that For Example
form 13 june to 15 june data are here
Kind Regards
SrikkanthMSomething like this can also indicate the first and last rows as you query...
SQL> select empno, ename, hiredate
2 ,case row_number() over (order by hiredate)
3 when 1 then 'First Row'
4 when count(*) over () then 'Last Row'
5 end as flag
6 from emp;
EMPNO ENAME HIREDATE FLAG
7369 SMITH 17/12/1980 00:00:00 First Row
7499 ALLEN 20/02/1981 00:00:00
7521 WARD 22/02/1981 00:00:00
7566 JONES 02/04/1981 00:00:00
7698 BLAKE 01/05/1981 00:00:00
7782 CLARK 09/06/1981 00:00:00
7844 TURNER 08/09/1981 00:00:00
7654 MARTIN 28/09/1981 00:00:00
7839 KING 17/11/1981 00:00:00
7900 JAMES 03/12/1981 00:00:00
7902 FORD 03/12/1981 00:00:00
7934 MILLER 23/01/1982 00:00:00
7788 SCOTT 19/04/1987 00:00:00
7876 ADAMS 23/05/1987 00:00:00 Last Row
14 rows selected.
SQL> -
How to get last row and sum of all columns in one query
Hi ,
is there a way to get last record for a column and sum of all record for another column in the same query.
Best Regards ,You should define your requirements properly for volunteers to help here..
Your data is not good enough to provide you accurate solution. Reason being you dont have a proper column which differentiates between first and last entry.
The solution becomes easy based on your desgin.
I have introduced a grouping column called "id" and a time column called "time_of_insert" (only this way you can confidently say that you can differentiate between first and last (also a fool proof solution) --- you may optionally use sequence(instead of date though if you say you may end up inserting two rows at the same time, then probably sequence would be a better choice to differentiate rather than a timestamp field) etc...)
With your sample data something like this can be done to achieve your desired result.
WITH dataset AS
(SELECT 1 id,10 used, 8 remain,systimestamp+1/24 time_of_insert FROM DUAL
UNION ALL
SELECT 1 id, 1, 7,systimestamp+2/24 FROM DUAL
UNION ALL
SELECT 1 id,2, 5,systimestamp+3/24 FROM DUAL
UNION ALL
SELECT 1 id,1, 0,systimestamp+4/24 FROM DUAL
UNION ALL
SELECT 1 id,0, 0,systimestamp+5/24 FROM DUAL
UNION ALL
SELECT 1 id,1, 4,systimestamp+6/24 FROM DUAL)
SELECT *
FROM (SELECT SUM (used) OVER () sum_all,
FIRST_VALUE (remain)
OVER (PARTITION BY id ORDER BY time_of_insert DESC)
last_row
FROM dataset)
WHERE ROWNUM = 1;
Output:
SUM_ALL LAST_ROW
15 4
Cheers,
Manik. -
QUery retrieving based on previous and after rows.. pls help
CREATE TABLE "POP"."RP06"
( "NUM" NUMBER(7,0),
"SEQ_LINE" NUMBER(7,0),
"CHMP" VARCHAR2(4000 BYTE)
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,1,'( ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,2,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,3,'AND ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,4,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,5,'OR ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,6,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,7,'AND /*4*/ ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,8,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,9,'OR ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,10,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,11,'AND ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,12,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,13,'OR ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,14,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,15,'OR ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,16,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,17,'AND ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,18,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,19,') ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,20,'AND /*10*/ ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,21,'ORACLE IS GREAT');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,22,'AND /*11*/ ');
Insert into RP06 (NUM,SEQ_LINE,CHMP) values (100,23,'ORACLE IS GREAT');after inserting the rows i want to retrieve the rows as follows
1 select the chmp which satisfied the condition if the chmp has previous row is 'AND'* and next row 'OR'* example: chmp with seq_line 4 which has previous 'AND' in seq_line 3 and 'OR' in seq_line 5. so retrieve the 4th seq_line chmp.
( CHMP WITH SEQ_LINE 8,12 ARE other EXAMPLES)
2) select the chmp which satisfied the condition if the chmp has previous row is *'OR' and next row 'AND'*
example: chmp with seq_line 10 which has previous 'OR' in seq_line 9 and 'AND' in seq_line 11. so retrieve the 10th seq_line chmp.
( CHMP WITH SEQ_LINE 6,16 ARE other EXAMPLES)
Kindly help
SHi,
You can use the analytic LAG function to get the value from the last row before a given row, and
you can use the analytic LEAD function to get the value from the next row after a given row.
For example:
WITH got_neighbors AS
SELECT num, seq_line, chmp
, LAG (chmp) OVER ( PARTITION BY num
ORDER BY seq_line
) AS prev_chmp
, LEAD (chmp) OVER ( PARTITION BY num
ORDER BY seq_line
) AS next_chmp
FROM rp06
-- WHERE ... -- Any filtering goes here
SELECT num, seq_line, chmp
FROM got_neighbors
WHERE prev_chmp LIKE 'AND %'
AND next_chmp LIKE 'OR %'
;I assume that your real table can have many values for num, and that when you talk about the "earlier" or "next" row, you mean a row with the same num. If that's not the case, then remove "PARTITION BY num".
Analytic functions are computed after the WHERE clause is applied, so to use the results of analytic functions in a WHERE clause, compute them first in a sub-query (such as got_neighbors), and then use them in the WHERE clause of a super-query. -
Getting first and last records of sql using a analytical function query
hi all!
Thanks in advance for looking at my problem! I have a query that runs against a table that keep all records
of changes on another table (journal table kind of thing). I wrote a sql that would tell what the status of that
requisition was, what came next and its respective dates. However, that would bring a lot of rows. I only need
to see the first row and last couple say 3 last rows. How could I achieve that?
SELECT ano yr,
numero id,
jn_datetime,
status_siafi status,
lead(status_siafi) over(PARTITION BY ano, numero ORDER BY jn_datetime) next_status,
lead(jn_datetime) over(PARTITION BY ano, numero ORDER BY jn_datetime) date_next_status,
MAX(jn_datetime) over(PARTITION BY ano, numero) last_update,
MIN(jn_datetime) over(PARTITION BY ano, numero) first_update
FROM nl_compensado_jn
WHERE ano = '08'
AND numero = '113747'
GROUP BY ano,
numero,
jn_datetime,
status_siafi
YR ID JN_DATETI S N DATE_NEXT LAST_UPDA FIRST_UPD
08 113747 11-SEP-08 1 2 11-SEP-08 20-NOV-08 11-SEP-08
08 113747 11-SEP-08 2 3 12-SEP-08 20-NOV-08 11-SEP-08
08 113747 12-SEP-08 3 2 12-SEP-08 20-NOV-08 11-SEP-08
08 113747 12-SEP-08 2 3 15-SEP-08 20-NOV-08 11-SEP-08
08 113747 15-SEP-08 3 2 15-SEP-08 20-NOV-08 11-SEP-08
08 113747 15-SEP-08 2 3 16-SEP-08 20-NOV-08 11-SEP-08
08 113747 16-SEP-08 3 2 16-SEP-08 20-NOV-08 11-SEP-08
08 113747 16-SEP-08 2 3 17-SEP-08 20-NOV-08 11-SEP-08
08 113747 17-SEP-08 3 2 17-SEP-08 20-NOV-08 11-SEP-08
08 113747 17-SEP-08 2 3 18-SEP-08 20-NOV-08 11-SEP-08
08 113747 18-SEP-08 3 2 18-SEP-08 20-NOV-08 11-SEP-08
08 113747 18-SEP-08 2 3 19-SEP-08 20-NOV-08 11-SEP-08
08 113747 19-SEP-08 3 2 19-SEP-08 20-NOV-08 11-SEP-08
08 113747 19-SEP-08 2 3 23-SEP-08 20-NOV-08 11-SEP-08
08 113747 23-SEP-08 3 2 24-SEP-08 20-NOV-08 11-SEP-08
08 113747 24-SEP-08 2 3 25-SEP-08 20-NOV-08 11-SEP-08
08 113747 25-SEP-08 3 2 25-SEP-08 20-NOV-08 11-SEP-08
08 113747 25-SEP-08 2 3 26-SEP-08 20-NOV-08 11-SEP-08
08 113747 26-SEP-08 3 2 26-SEP-08 20-NOV-08 11-SEP-08
08 113747 26-SEP-08 2 3 29-SEP-08 20-NOV-08 11-SEP-08
08 113747 29-SEP-08 3 2 29-SEP-08 20-NOV-08 11-SEP-08
08 113747 29-SEP-08 2 3 02-OCT-08 20-NOV-08 11-SEP-08
08 113747 02-OCT-08 3 2 02-OCT-08 20-NOV-08 11-SEP-08
08 113747 02-OCT-08 2 3 03-OCT-08 20-NOV-08 11-SEP-08
08 113747 03-OCT-08 3 2 03-OCT-08 20-NOV-08 11-SEP-08
08 113747 03-OCT-08 2 3 06-OCT-08 20-NOV-08 11-SEP-08
08 113747 06-OCT-08 3 2 06-OCT-08 20-NOV-08 11-SEP-08
08 113747 06-OCT-08 2 3 07-OCT-08 20-NOV-08 11-SEP-08
08 113747 07-OCT-08 3 2 07-OCT-08 20-NOV-08 11-SEP-08
08 113747 07-OCT-08 2 3 08-OCT-08 20-NOV-08 11-SEP-08
08 113747 08-OCT-08 3 2 08-OCT-08 20-NOV-08 11-SEP-08
08 113747 08-OCT-08 2 3 09-OCT-08 20-NOV-08 11-SEP-08
08 113747 09-OCT-08 3 2 09-OCT-08 20-NOV-08 11-SEP-08
08 113747 09-OCT-08 2 3 10-OCT-08 20-NOV-08 11-SEP-08
08 113747 10-OCT-08 3 2 14-OCT-08 20-NOV-08 11-SEP-08
08 113747 14-OCT-08 2 3 15-OCT-08 20-NOV-08 11-SEP-08
08 113747 15-OCT-08 3 2 15-OCT-08 20-NOV-08 11-SEP-08
08 113747 15-OCT-08 2 3 16-OCT-08 20-NOV-08 11-SEP-08
08 113747 16-OCT-08 3 2 16-OCT-08 20-NOV-08 11-SEP-08
08 113747 16-OCT-08 2 3 17-OCT-08 20-NOV-08 11-SEP-08
08 113747 17-OCT-08 3 2 17-OCT-08 20-NOV-08 11-SEP-08
08 113747 17-OCT-08 2 3 21-OCT-08 20-NOV-08 11-SEP-08
08 113747 21-OCT-08 3 2 21-OCT-08 20-NOV-08 11-SEP-08
08 113747 21-OCT-08 2 3 22-OCT-08 20-NOV-08 11-SEP-08
08 113747 22-OCT-08 3 2 22-OCT-08 20-NOV-08 11-SEP-08
08 113747 22-OCT-08 2 3 23-OCT-08 20-NOV-08 11-SEP-08
08 113747 23-OCT-08 3 2 23-OCT-08 20-NOV-08 11-SEP-08
08 113747 23-OCT-08 2 3 27-OCT-08 20-NOV-08 11-SEP-08
08 113747 27-OCT-08 3 2 27-OCT-08 20-NOV-08 11-SEP-08
08 113747 27-OCT-08 2 3 28-OCT-08 20-NOV-08 11-SEP-08
08 113747 28-OCT-08 3 2 28-OCT-08 20-NOV-08 11-SEP-08
08 113747 28-OCT-08 2 3 29-OCT-08 20-NOV-08 11-SEP-08
08 113747 29-OCT-08 3 2 29-OCT-08 20-NOV-08 11-SEP-08
08 113747 29-OCT-08 2 3 30-OCT-08 20-NOV-08 11-SEP-08
08 113747 30-OCT-08 3 2 30-OCT-08 20-NOV-08 11-SEP-08
08 113747 30-OCT-08 2 3 31-OCT-08 20-NOV-08 11-SEP-08
08 113747 31-OCT-08 3 2 31-OCT-08 20-NOV-08 11-SEP-08
08 113747 31-OCT-08 2 3 03-NOV-08 20-NOV-08 11-SEP-08
08 113747 03-NOV-08 3 2 03-NOV-08 20-NOV-08 11-SEP-08
08 113747 03-NOV-08 2 3 06-NOV-08 20-NOV-08 11-SEP-08
08 113747 06-NOV-08 3 2 06-NOV-08 20-NOV-08 11-SEP-08
08 113747 06-NOV-08 2 3 07-NOV-08 20-NOV-08 11-SEP-08
08 113747 07-NOV-08 3 2 07-NOV-08 20-NOV-08 11-SEP-08
08 113747 07-NOV-08 2 3 10-NOV-08 20-NOV-08 11-SEP-08
08 113747 10-NOV-08 3 2 10-NOV-08 20-NOV-08 11-SEP-08
08 113747 10-NOV-08 2 3 12-NOV-08 20-NOV-08 11-SEP-08
08 113747 12-NOV-08 3 2 12-NOV-08 20-NOV-08 11-SEP-08
08 113747 12-NOV-08 2 3 13-NOV-08 20-NOV-08 11-SEP-08
08 113747 13-NOV-08 3 2 13-NOV-08 20-NOV-08 11-SEP-08
08 113747 13-NOV-08 2 3 14-NOV-08 20-NOV-08 11-SEP-08
08 113747 14-NOV-08 3 2 14-NOV-08 20-NOV-08 11-SEP-08
08 113747 14-NOV-08 2 3 17-NOV-08 20-NOV-08 11-SEP-08
08 113747 17-NOV-08 3 2 17-NOV-08 20-NOV-08 11-SEP-08
08 113747 17-NOV-08 2 3 18-NOV-08 20-NOV-08 11-SEP-08
08 113747 18-NOV-08 3 2 18-NOV-08 20-NOV-08 11-SEP-08
08 113747 18-NOV-08 2 2 18-NOV-08 20-NOV-08 11-SEP-08
08 113747 18-NOV-08 2 3 19-NOV-08 20-NOV-08 11-SEP-08
08 113747 19-NOV-08 3 2 19-NOV-08 20-NOV-08 11-SEP-08
08 113747 19-NOV-08 2 4 20-NOV-08 20-NOV-08 11-SEP-08
08 113747 20-NOV-08 4 20-NOV-08 11-SEP-08
80 rows selected.thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!
gleisson henriquesorry!!!!! didn't notice that major detail!!!
insert into nl_compensado_jn values ('INS','LETICIA','11-SEP-08 15:08:27','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','1','');
insert into nl_compensado_jn values ('UPD','BELLA','19-SEP-08 07:43:20','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','18-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','15-SEP-08 07:45:54','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','12-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','11-SEP-08 15:34:30','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','11-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','16-SEP-08 13:48:38','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','16-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','18-SEP-08 07:44:12','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','17-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','16-SEP-08 07:38:29','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','15-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','19-SEP-08 16:13:20','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','19-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','18-SEP-08 15:33:59','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','18-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','15-SEP-08 15:35:52','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','15-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','02-OCT-08 07:51:38','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','29-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','26-SEP-08 08:11:04','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','25-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','29-SEP-08 15:46:31','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','29-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','29-SEP-08 12:12:29','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','26-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','08-OCT-08 07:44:06','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','07-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','09-OCT-08 07:44:43','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','08-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','03-OCT-08 07:44:57','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','02-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','06-OCT-08 07:41:19','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','03-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-SEP-08 07:35:00','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','16-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','03-OCT-08 15:17:09','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','03-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','23-SEP-08 16:05:01','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','19-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','25-SEP-08 07:37:44','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','24-SEP-08');
insert into nl_compensado_jn values ('UPD','GERENTE','26-SEP-08 15:57:35','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','26-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','24-SEP-08 15:31:40','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','24-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','12-SEP-08 08:02:34','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','11-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','09-OCT-08 15:04:27','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','09-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-SEP-08 15:31:46','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','17-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','07-OCT-08 07:51:57','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','06-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','07-OCT-08 15:04:54','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','07-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','02-OCT-08 15:49:48','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','02-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','25-SEP-08 15:36:45','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','25-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','06-OCT-08 15:00:08','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','06-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','08-OCT-08 14:57:23','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','08-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','12-SEP-08 15:31:47','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','12-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','06-NOV-08 10:04:08','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','03-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','10-NOV-08 14:11:55','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','07-NOV-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','23-OCT-08 15:08:23','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','23-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','31-OCT-08 14:59:36','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','31-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','28-OCT-08 10:33:59','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','27-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','16-OCT-08 08:01:41','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','15-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','29-OCT-08 11:04:35','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','28-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-OCT-08 07:58:07','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','16-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','22-OCT-08 10:36:15','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','21-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','21-OCT-08 13:08:38','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','17-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','23-OCT-08 10:49:52','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','22-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','27-OCT-08 10:12:47','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','23-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','16-OCT-08 15:36:47','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','16-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','14-OCT-08 15:19:24','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','14-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','03-NOV-08 09:10:26','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','31-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','15-OCT-08 07:59:37','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','14-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','10-OCT-08 11:25:23','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','09-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','03-NOV-08 16:01:49','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','03-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','29-OCT-08 15:13:36','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','29-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','22-OCT-08 15:25:48','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','22-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','30-OCT-08 10:22:24','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','29-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','30-OCT-08 15:15:47','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','30-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-OCT-08 15:19:19','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','17-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','06-NOV-08 16:08:43','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','06-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','31-OCT-08 10:42:10','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','30-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','07-NOV-08 16:01:50','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','07-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','21-OCT-08 15:34:07','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','21-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','27-OCT-08 15:22:24','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','27-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','28-OCT-08 15:16:19','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','28-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','15-OCT-08 15:15:54','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','15-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','07-NOV-08 09:39:43','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','06-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-NOV-08 09:29:29','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','14-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','12-NOV-08 09:40:53','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','10-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','18-NOV-08 09:49:53','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','17-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','19-NOV-08 15:29:15','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084810','16660','2','19-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','10-NOV-08 15:25:03','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','10-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','13-NOV-08 09:10:07','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','12-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','14-NOV-08 10:33:24','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','13-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','12-NOV-08 15:32:54','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','12-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-NOV-08 15:37:10','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','17-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','19-NOV-08 09:14:38','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084810','16660','3','18-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','20-NOV-08 09:06:16','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084810','16660','4','19-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','14-NOV-08 15:19:03','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','14-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','18-NOV-08 15:47:14','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','18-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','13-NOV-08 15:29:06','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','13-NOV-08');
insert into nl_compensado_jn values ('UPD','HEBER','18-NOV-08 18:41:45','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084810','16660','2','18-NOV-08'); -
Ora-01847 day of month between 1 and last date of month coming in my query
i m executing simple query but it is not working plz do help
select *
from sgvf_tree_nodes_vw
where to_date(node_attr9_val, 'dd/mm/yyyy') between
to_date('01/01/2010', 'dd/mm/yyyy') and
to_date('31/12/2010', 'dd/mm/yyyy')
gives : Ora-01847 day of month should be between 1 and last date of monthHi,
Check the date format's once
SQL> drop table demo;
Table dropped.
SQL> create table demo(val number, todate varchar2(12));
Table created.
SQL> insert into demo values(1,'04/11/2008');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from demo;
VAL TODATE
1 04/11/2008
SQL> select sysdate from dual;
SYSDATE
03-FEB-11
SQL> insert into demo values(1,'04/11/2010');
1 row created.
SQL> commit;
Commit complete.
SQL> select *
2 from demo
3 where to_date(todate,'dd/mm/yyyy') between to_date('01/01/2010', 'dd/mm/yyyy') and to_date('31/12/2010', 'dd/m
m/yyyy');
VAL TODATE
1 04/11/2010- Pavan Kumar N -
How to get the last row in a resultset or query
Hi All
Say If I have a complex query which returns a resultset say 15 rows. Now I want to limit the output showing only the last row.
How can we do thisKeep in mind Oracle does not keep "row" order as such. Unlike a graphical type db like Access, Oracle will not always give you back the results in order.
Even if you were to use a sequence, your query is never guaranteed to give back the results in the order you are expecting. You must then give an order by statement to all queries expecting the order.
Your definition of last row too is vague - if it is in fact the greatest amount, use the inline view suggestion. If you simply want to see the last inserted row, consider adding a last_update_date column inserting the sysdate (by a trigger perhaps). This would then allow you to see the last inserted row.
Enjoy! -
Needs help to retrive the last row in a select query without using rownum
Hi ,
i need to retrive the last row from the select sub query without using rownum.
is there any other way to retrive the last row other than the below query.
is that the ROWNUM=1 will always retrive the 1 row of the select query ?
select from*
*(select ename from employee where dept_id=5 order by desc) where rownum=1;*
Please advise.
thanks for your help advance,
regards,
Senthur957595 wrote:
Actually my problem is ithat while selecting the parents hiearchy of the child data using
CONNECT BY PRIOIR query
I need the immediate parent of my child data.
For example my connect BY query returns
AAA --- ROOT
BBB --PARENT -2
CCC --PARENT-1
DDD IS my input child to the connect by query
Immediate parent of my child data "DDD" ---> CCC(parent -1)
i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
So confusing with using this rownum in my query.
Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
you can select the PRIOR values to get the parent details if you want...
SQL> ed
Wrote file afiedt.buf
1 select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
2 from emp
3 connect by mgr = prior empno
4* start with mgr is null
SQL> /
EMPNO ENAME MGR
7839 KING
7566 JONES 7839
7788 SCOTT 7566
7876 ADAMS 7788
7902 FORD 7566
7369 SMITH 7902
7698 BLAKE 7839
7499 ALLEN 7698
7521 WARD 7698
7654 MARTIN 7698
7844 TURNER 7698
7900 JAMES 7698
7782 CLARK 7839
7934 MILLER 7782
14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data) -
How to display a empty (non-existing) column and info in LAST row
Hello!
I´m trying to create the code that diplays all authors (author.name), empty COLUMN, NR_OF_BOOK_PER_AUTHOR.
I want the LAST ROW to display: (column1) the word 'Sum:', (column2) nr of authors, (column3) total sum of all books
Headache: How do I display the EMPTY column and how do I get the LAST ROW to display column1) 'Sum:', (column2) nr of authors, (column3) total sum of all books
It should look like this:
AUTHOR EMPTY NR_OF_BOOKS_PER_AUTHOR
I can list all authors and NR_OF_BOOKS_PER_AUTHOR using this code:
SELECT A.NAME, COUNT(B.ROWID)
FROM AUTHOR A, BOOK B
WHERE B.AUTHOR_ID = A.ID
GROUP BY A.NAME
ORDER BY COUNT(B.ROWID)
I can count the numbers of authors (should be displayed in last row column2) using:
SELECT COUNT(name)
FROM author
and I can list the total amount of books (should be displayed in last row column3) using:
SELECT COUNT(title)
FROM book
But I come up short with how to display the EMPTY column and the last row containing (column1) the word 'Sum:', (column2) nr of authors, (column3) total sum of all books
Any suggestions?
Best regards,
DanielI want the LAST ROW to display: (column1) the word 'Sum:', (column2) nr of authors, (column3) total sum of all booksHave a look at GROUP BY with CUBE or ROLLUP.
Cheers, APC -
IBM SVC console uses websphere. Screen data that is presented in table form last row appears to overwrite the prior row only. In other similar layouts, the last row is cut in half and cannot be seen. The prior version of Firefox 3 (something) did not have this problem. OS Windows XP Pro SP3
Firefox V3.6.17 worked fineSeeing the same problem using the HMC with FF7 beta.
-
Query : first and last 25 records of a table
Hi @ll,
i am going to write a query for a report. Therefor i need the first and last 25 records of a table. Does anyone got an idea for a solution ? I was trying to achieve this by using a WHERE clause. Here is a part of the query :
SELECT
TOP 10 T1.[ItemCode], DATEPART(mm, T1.[DocDate]) [.....]
FROM FROM INV1 T1
Where T1.[DocDate] >= Cast('2009 [......] AND
T1.ItemCode = (
SELECT TOP 10 T40.[ItemCode]
FROM DBO.OINM
WHERE Where T40.[DocDate] >= Cast('2009-04-01 00:00:00' AS datetime)
AND T40.[DocDate] <= Cast('2009-04-30 00:00:00' AS datetime)
GROUP BY T1.[ItemCode], DATEPART(mm, T40.[DocDate])
ORDER BY SUM(T1.[TotalSumSy]) ASC)
The where part i would use twice, once for ascending the other one for descending. But it does not work.
Any ideas ?
Regards SteffenHi,
Union was the keyword, that i was searching for. It is a nice way, but not practible.
We are using coresuite for generating reports, and there were a nice possibility to connect diffrent queries.
Thanks for your suggestion.
Regards Steffen
Maybe you are looking for
-
How to post a link (URL) in "Apple Discussions"
You can shorten your links (URLs) by using HTML coding. This is preferable when the URL is very long. Posting the entire URL can extend the width of a post beyond the range of many computer screens. This can make a post difficult to read, as it neces
-
RoboHelp 10 can't update linked FrameMaker book
TCS 4 Linked FrameMaker book HTML Help output When I open a previously working project and go to update the FrameMaker files, the Update and Update All options are greyed out. A possible culprit is that Windows Update ran automatically while the proj
-
Safari crashes when editing a 'note' in Yahoo! Notepad
Can I get some feedback about the crash tracked in the following crash report -- a new type of Safari crash in my experience since I wasn't doing anything media-intensive, just editing a 'note' in Yahoo! Notepad. Thanks. Date/Time: 2007-11-25 00:02:2
-
Installing iTunes 7.0.2 on Windows Vista X64
Hey guys, Sorry if this has been covered in the past, I looked over the forum and couldn't find anything on this. However I have a solution for installing iTunes 7.0.2 on Windows Vista x64. What was happening was that anytime I installed iTunesSetup.
-
Could someone kindly advise if On a Mac G5 ... if a FW400 perhiperal could also be used the FW800 port ? Thanks