Earliest & Latest Dates With * Other Columns
Hi friends,
I have data in a single table as:
Customer_ID (VarChar, Key)
Customer_Name
Transaction_Date
Transation_Amount
What query could get me all the four fields with two additional fields reflecting the Earliest and the Latest dates of transactions of the Customer with his/her ID being used? Some Sub-Query & Joins?
Best Regards, Faraz A Qureshi
I reckon this is what you need
select Customer_ID,
Customer_Name,
Transaction_Date,
Transation_Amount,
Min(Transaction_Date) over (Partition by Customer_ID) Early_Date,
Max(Transaction_Date) over (Partition by Customer_ID) Latest_Date
from <<your tablename>>
--If this helps kindly mark it as answer
Similar Messages
-
How to get only latest date and other columns from table
Hi,
Table
id name date
123 a 2/3/2010
124 b 15/2/2010
125 c 1/1/2010
123 a 12/4/2010
125 c 17/2/2010
this is a table, here id,name,date is composite key.
I want to select id,name and date so that latest date (e.g., for id 123 date 12/4/2010 be selected) is selected for each id and each id and name should be selected once.
So what will be its query?
ThanksHi,
user12222356 wrote:
SQL> select id id,name name,max(dt) over 0 from temp2;
select id id,name name,max(dt) over 0 from temp2
ERROR at line 1:
ORA-00923: FROM keyword not found where expectedWhat is over 0?That should be
... OVER ( )with a pair of parentheses.
Almost all aggregate functions (including MAX) also have analytic counterparts. The parser knows that you're using the analytic version if the keyword OVER, followed by an analytic clause in parentheses, comes after the argument. In this case, the default analytic clause is being used, so there's no need to put anything in the parentheses, but syntax still requires that they be there. -
MathScript Nugget #19: Sharing Data With Other Applications
In MathScript Nugget #18, we looked at ways to transfer data between MathSript and the rest of LabVIEW. In today's nugget, we'll see some of the different ways that MathScript can share data with programs besides LabVIEW.
The most common way to share data between programs is by reading and writing files. MathScript supports several file formats that are recognized by other programs. The ones we'll touch on in this nugget are MLV, MAT, CSV, TXT, TDM(S) and XLS.
The easiest way to bring data into MathScript is with the 'load' function. The help topic for this function does a great job of explaining it. The load function will bring in a group of variables that have been saved to a file earlier. The most common formats that load supports are:
MLV files created with MathScript save function
MAT files created with version 6.0 or earlier of The MathWorks, Inc. MATLAB® software
TDM and TDMS binary measurement files created in LabVIEW or DIAdem
The load and save functions are great for storing off a group of variables to be used again in a future session of MathScript. You can do the same thing using the Operate>>Load Data... and Operate>>Save Data... menu items in the MathScript Window. These support the same file formats as load and save.
The best formats to use if you want to share data with other applications are TXT, CSV, and XLS. MathScript has special funcitons to read and write each of these formats. The functions, such as fread_csv and fwrite_xls, are all members of the support class.
The last way to read and write data files with MathScript is to use a custom file format. MathScript supports common file operations like fread and fwrite. You can use these functions to create or import files of any binary or textual format.
There's one last way to move data out of MathScript without using files. You can copy data from the MathScript Window or MathScript Probe as tab-delimited text to your OS clipboard. You can then paste this text to a text editor or spreadsheet program.
Hopefully now you have an idea of the many ways to move data into and out of MathScript.
MATLAB® is a registered trademark of The MathWorks, Inc.
jattas
LabVIEW MathScript R&D
ps Check out more MathScript Nuggets!TDM and TDMS are also excellent file formats to share your data with other applications. National Instrumenst offers free libraries and add-ins to access TDM and TDMS files with e.g. Excel, OpenOffice Calc or The MathWorks, Inc. MATLAB® software. Have a look at this page to
Find Resources for Reading and Writing TDMS Files in Third-Party Products -
Discoverer: Capturing record with the latest date among others
Hi there,
I would appreciate if anyone can help me in Discoverer10g Report. The report gives me the following results. Let me know if any more info needed.
Example:
Plan Cov St Dt Amt Elec. Dt Name Rt St dt Comm Ann Enrl Cov St Dt
Basic Life 01-JAN-2011 76000.00 11-NOV-2010 Stephanie 01-JAN-2011 2.63 68.40 11-NOV-2010
Basic Life 01-JAN-2011 76000.00 29-OCT-2010 Stephanie 01-JAN-2011 2.63 68.40 29-OCT-2010 (Yes)
Basic Life 01-JAN-2011 177000.00 29-OCT-2010 Shanika 01-JAN-2011 6.13 159.30 29-OCT-2010 (Yes)
Basic Life 01-JAN-2011 214000.00 19-NOV-2010 Nicole 01-JAN-2011 7.41 192.60 19-NOV-2010 (Yes)
Basic Life 01-JAN-2011 214000.00 29-OCT-2010 Nicole 01-JAN-2011 7.41 192.60 29-OCT-2010
What I want to capture is latest date record from available records of the same employee and if there is only one record, I would want that too. In short, the ones which has '(yes)' at the end.
What function can I use to get the desired results.
Thank you!
NNHi Tamir,
I used the the function(for another report which has similar situation) you mentioned but it gives me an error saying-
ORA-01858: a non-numeric character was found where a numeric was expected.
Its is OAB module indeed. some how due to date issue during our Insurance Vendor changes, I get multiple records of the same employees with some blank fields. See the example below.
*4.36 07-AUG-2010 31-DEC-4712 07-AUG-2010 07-AUG-2010 21206*
NULL 07-AUG-2010 31-DEC-4712 07-AUG-2010 21206
3.95 01-JAN-2010 31-DEC-4712 01-JAN-2010 01-JAN-2010 21206
Now out of three I need the one in bold letters. and there are other employees having just one record like
Amt Cov_St_DT Cov_End_Dt Rate_St_Date Rt_Effective Dt EEID
1.45 15-SEP-2010 31-DEC-4712 15-SEP-2010 15-SEP-2010 22777
7.65 01-JAN-2010 31-DEC-4712 01-JAN-2010 01-JAN-2010 21298
so I need the single records as well as latest(date) record of multiple records of one employee.
Let me know if you need more information.
One more thing- is there any way to see the actual query I am running?(not sql Inspector)
Thank you!
797174
p.s Thank you for the earlier reply.
Edited by: 797174 on Dec 21, 2010 2:18 PM -
Matrix report data with summary column in excel format
Hi ,
I want to display output of matrix report with summary column in excel format.
I have tried using spreadsheet but column header and actual data is displaying in proper order.
Please tell me the way how to do this ASAP.
Thanks in advance.Hi ,
I want to display output of matrix report with summary column in excel format.
I have tried using spreadsheet but column header and actual data is displaying in proper order.
Please tell me the way how to do this ASAP.
Thanks in advance. -
How to use SQL*Loader to load XMLType Column with other columns?
Hi,
I am trying to use sqlldr to load an XML file into a table with an XMLType column. I have found plenty of examples where the entire table is an xmltype, but I would like to load many XML objects into a generic table for processing with one XMLType column and many other columns to identify the load. As a simple example, I have one constant column which I want to set during the upload.
The following example does not work :(. No errors either.
create table xml_upload
(upload_type varchar2(10) not null,
xml_data XMLType)
my control file:
LOAD DATA
INFILE * append
INTO TABLE xml_upload
XMLType(xml_data)
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
upload_type constant MARKET,
xml_data
BEGINDATA
<SALE_ORDER>
<CUST_CODE>TIM</CUST_CODE>
<ORDER_NUM>1234></ORDER_NUM>
</SALE_ORDER>
$ sqlldr my.ctl
SQL*Loader: Release 10.2.0.4.0 - Production on Sun Sep 27 22:51:52 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Commit point reached - logical record count 4
SQL> select * from xml_upload;
no rows selected
SQL>
Any ideas on how I can do this? Am I missing something...
I have also been playing with the lobfile clause of sqlldr, also without any success...
Current database version is 10g R2.
Thanks,
Tim.Hi,
I tried the same example as it is. but, I am getting the following error:
SQL*Loader-350: Syntax error at line 6.
Expecting valid column specification, "," or ")", found "filler".
,file_name char(100) fillerThe table I created is:
create table xml_upload
(upload_type varchar2(10) not null,
xml_data XMLType)The control file I used is:
LOAD DATA
INFILE *
INTO TABLE xml_upload TRUNCATE
upload_type constant 'MARKET'
,file_name char(100) filler
,xml_data LOBFILE (file_name) TERMINATED BY EOF
BEGINDATA
test.xmlThe database I am using is 10gr2 -
Getting a column in numbers '09 to not sort along with other columns
How do I have a header column not sort along with the other columns. for example, if I have a spread sheet with all my contacts and there is a numbers header column on the left, how do I get the last name column to sort but not have the header column sort along with it?
Patrick
Ohiopmalone wrote:
How do I have a header column not sort along with the other columns. for example, if I have a spread sheet with all my contacts and there is a numbers header column on the left, how do I get the last name column to sort but not have the header column sort along with it?
Feature unavailable.
We sort every columns or none of them.
Yvan KOENIG (VALLAURIS, France) vendredi 18 septembre 2009 19:23:57 -
Merging Inventory Data With Other Data
Dear Experts,
I have a requirement where in i am trying to combine Inventory Data with data from other datasource (0CO_PC_ACT_05).
I have designed the Bex query from both the sources. Now i have tried to merge the data at BO level by merging dimesions
plant and material. It works fine for small data set but there is performance issue as we have huge inventory data of more than 15 years.
Kindly suggest me the other methods through which i can merge the data.
Thanks ,
SumitHi! Rajesh,
The input for Inventory Query is Plant,calender date,storage location, material type.
For Material Ledger query the input is fiscal year/period and plant.
I have merged the dimensions Plant and material at BO level.
Thanks
Sumit -
Recording birthday dates with other contact information
I would like to be able to record birthday dates along with other contract info in my phone directory and at the same time, have my calendar app. "remember" and "record" these dates so that I will automatically be reminded of upcoming birthdays without making a separate entry.
I could do that on my Blackberry but not with the Razr. Any suggestions.
Pjone3rdI remember signing into my Google calendar from a computer and adding a calendar called contacts birthdays. Then whichever Gmail/Google contacts had birthdays and any I added afterwards were added to that calendar and synced with my phone.
Hope this helps. -
How to show Relevance% along with other columns
I need to retieve the Relevance % in adddition to other columns
in a table? How can I get the Relevance %?
Thanks.The Score(1) does return a number but it is not the number we
are looking for. For example, we have a column, say,
Description in a table. The Decsription column has text,
say, 'Telecom'. Now when we do a query and search on the
description column using the intermedia index for the
word 'Telecom', then the Score(1) should return 100 for that
record since that is the only word in the Decsription column.
Is it possible to do that using intermedia?
Thanks. -
How to display data with dynamic columns in JavaServerFaces?
I have a simple JSF application, where I click a button, it will display another page with data table of 2 columns and 3 rows of data. These data are �hard coded� for testing only.
In the jsp I will use like this:-
<h:dataTable
value="#{dataBean.users}"
var="record">
<h:column>
<h:outputText value="#{record.name}"/>
</h:column>
<h:column>
<h:outputText value="#{record.title}"/>
</h:column>
</h:dataTable>
Let�s say, if my data cannot be defined in advance in terms of quantity and names, how should I write my jsp and how should I define in java program?
For example, instead of the columns �name� and �title� as in above, I will know the column names and the number of columns at run time, how should I do?You need a custom component in this case. There afew out there, you may want to check what is out there before you write your own
-
Second row data - First row data of other column?
Hi All,
I have a requirement to show the second row data of the column1 as first row in column2. Please see the example below, where month is filtered <= 05.
Month Sales Sales_New
01 500 600
02 600 700
03 700 800
04 800 900
05 900 NULLIn the above example for month 05, column Sales_New should show NULL because it is the last row of the query.
Thanks in advance.Something gone wrong with your config....!!
How about
"In Criteria tab use Month descending order and in Pivot table use ascending order"
This is mandatory to achieve this..
FYI: I've tested this in my local.
If you need will send screenshot
I appreciate if you mark as correct ;) else let me know -
Data with XMLTYPE column are not being shown after importing.
I have installed Oracle 10.2 release on Win2000 machine. I have imported oracle 9.2.0.4.0 dump on this oracle 10.2 release. This was done fine. but the tables which have XMLTYPE as any columns,the data of those tables are not shown in the corrosponding user.
Can anyone guide me what should i do?
Thanks
MiteshHi CAMILO URIBE,
As far as I understood, the import does not take the calendar from MSproject, rather take a fixed one. The background is that, the MSproject using numric for calendar and the cProject uses characters. During the export, an automatic numric calendar ID is created for MsProject, but the mapping between Msproject and cProject calendar does not exit, so that the later importing action will ignore the Msproject calendar ID.
Search SAP notes in this topic should give more details.
Kind regards,
Zhenbo -
How to replace the string of column value with other column value in same table
I have a temp table which contains
Id Name CTC Address Content
1 Ross $200 6th block Dear #Name your CTC is #CTC and your address is #address
2 Jhon $300 1oth cross Dear #Name your CTC is #CTC and your address is #address
Now i want to select content so that it should get replace with the respective columns and final output should come like this
Dear Ross your CTC is 200 and your address is 6th block
Dear Jhon your CTC is 300 and your address is 10th cross
Kindly suggestI think RSingh suggestion is ok ... what do you mean by another way? ...maybe something more generic?
maybe build a table whith the list of col you need to "replace" and dinamically build the replace query ...
declare @colList table(colName varchar(100))
insert into @colList
select 'name'
union all select 'ctc'
union all select 'address'
declare @cmd varchar(2000)
select @cmd='select '+ (select 'replace(' from @colList for xml path('') +' content '+
(select ',''#'+ colName +''', '+ colName +')' from @colList for xml path(''))
+' from YOURTABLENAME '
exec (@cmd)
or your request was different ? -
Columns merged with other columns?
how do I achieve the following?
I want to have a tabular form as following
The first line of the tabular form will only be 3 columns (eg. col1,col2,col3). those three columns will then be broken down into 9 columns (ed. col1 - no column, col2 will have col4,col5,col6, and col7, col3 wil have col8 to col12.) on the second line.
Any ideas? I know it is possible to do with html but i'm not sure how to process it in APEXWhat I typically do first is to look at a report template from the current theme and see what CSS classes they are using against the tables, headers and rows. I will copy the entries to a text document so I can easily reference them.
The you create a new report template from scratch and as a Named Column (row template).
This type template allows you to specify where each column goes by using a substitution variable for the selected column.
The query I used in the example was
select ename, job, sal
from emp
For the Row Template 1 field under Row Template section, I put
<tr><td>#ENAME#</td><td>#JOB#</td><td>#SAL#</td></tr>
In the Before first and after last row text section I put
1. in the Before rows field
<style type="text/css">
table.outln {border-collapse:collapse;}
table.outln td {border: solid #000 1px;padding:5px;}
</style>
<table cellpadding="0" border="0" cellspacing="0" summary="" class="t9standardalternatingrowcolors outln" border="1">
<tr><th class="t9header" colspan="2">Name / Job</th><th class="t9header">Salary</th></tr>
2. In the After Rows field
</table>
This type of template is REALLY powerful. The only issues that I have run into in the past is that the order of the columns in your query should be the same as the order in which they are used in your row template. I am not sure if it is still an issue, but I have experience issues in the past that when you later change the query and the order is different then the rows are actually put in by position and not by name. To fix that problem I just drop the report and recreate.
If you happen to have my book by Oracle Press, HTML DB Handbook, there is a good description of this type of template on pages 211- 215.
The book is a little old now (almost 2 years). Just happened that they renamed HTML DB to ApEx the month before the book was published. It covers ver 2.0, but still has some good info in it.
Maybe you are looking for
-
How to extract data for particular two members of same dimension.
As per the requirement i need to export data for certain members of a dimension. Lets say we need data for two account members A and B which is in in Account dimension only but is not a direct children. I need the data for all the available years too
-
Fixing PATH (and MANPATH) once and for all
I think the list of directories in PATH should be: /Users/cb/bin: /opt/local/bin: /opt/local/sbin: /usr/local/bin: /usr/bin: /bin: /usr/local/sbin: /usr/sbin: /sbin: /usr/X11R6/bin: /usr/local/teTeX/bin/powerpc-apple-darwin-current Do you agree? Comm
-
HT1414 Lost contacts when trying to copy from iphone 3gs to iphone 5?
Hi All, I was trying to transfer iphone contacts from my old iphone to new one and followed the steps as mentioned on below link. http://techtips.salon.com/transferring-contacts-one-iphone-another-4973.html I realized all the contacts are now lost an
-
So i can connect my computer to my wrt110 wirelessly no problemo. When I try to connect my xbox 360, however, i can only connect to the router and not the internet. any help?
-
my i pad is disabled