Filter records with month and date
Hi,
i have records as follows in the table.
custno trn_dt amount
1 01-jan-06 100
1 10-jan-06 200 --->
1 15-feb-06 300
2 15-dec-06 111
2 15-jan-06 222 --->
2 01-fen-06 333
If i specify the runtime parameter as JAN-06 the output of the report should be with 2 records indicated with arrows above.
the query should pick up the record with the highest date for a specific customer.
in the above example for customer "1" 10-jan-06 is highest date and for customer "2" 15-jan-06 is the highest date.
hope the requirement is clear.
thanks in advance
SELECT custno, trn_dt, amount
FROM TABLE
WHERE (custno,trn_dt) IN
(SELECT custno, MAX(trn_dt)
FROM TABLE
GROUP BY custno)
There are many examples on this in SQL and PL/SQL forum.
Similar Messages
-
2lis_02_scl extract records with wrong posting date for Good Receipts.
Hi Experts,
We are currently having issue of mismatch between BW Schedule Line data with R/3 values for the Goods Receipts posting date updating incorrectly in to BW.
Example.
In table EKBE purchase order history we have following records.
MANDT EBELN EBELP ZEKKN VGABE GJAHR BELNR BUZEI BEWTP BWART BUDAT MENGE
501 5600453404 00010 00 1 2010 5012473031 0001 E 101 23.01.2010 1.250,000
501 5600453404 00010 00 1 2010 5012473031 0002 E 101 23.01.2010 1.250,000
501 5600453404 00010 00 1 2010 5012473031 0003 E 101 23.01.2010 1.250,000
501 5600453404 00010 00 1 2010 5012693310 0001 E 101 26.02.2010 1.250,000
Which means we have on posting date of 23.01.2010 1250*3 i.e. 3750 quantity of Goods Receipts.
However when we check the extractor we get multiple records in internal table C_T_DATA and in psa.
Line BWV ETENR SLFDT MENGE ROCA BEDAT BUDAT EBELN
ORG NCEL
1 001 0001 20100125 3750.000 20100113 ZNB F 00000000 5600453404
2 001 0002 20100226 1250.000 20100113 ZNB F 00000000 5600453404
3 002 0001 20100125 3750.000 X 20100113 ZNB F 20100123 5600453404
4 002 0001 20100125 3750.000 20100113 ZNB F 20100123 5600453404
5 003 0001 20100125 3750.000 X 20100113 ZNB F 20100127 5600453404
6 003 0001 20100125 3750.000 20100113 ZNB F 20100127 5600453404
7 002 0001 20100125 3750.000 X 20100113 ZNB F 20100226 5600453404
8 002 0001 20100125 3750.000 20100113 ZNB F 20100226 5600453404
9 002 0002 20100226 1250.000 X 20100113 ZNB F 20100226 5600453404
As can be seen we have record no 8 for ETENR (Schedule line 1) with posting date 26.02.2010 and another record with posting date 23.01.2010.
Since we are getting 2 records the record with incorrect posting date overwrites the record with correct one.
Any idea if this could be a standard extractor problem or any other way to resolve this issue.
Any help would be appreciated.First of all, are you using a staging DSO? (You should ideally)
If yes, is it a Write Optimized DSO? (Again, this is ideal)
If its a standard DSO, the values maybe over-writing upon activation.
You have 3 records (quantity = 1250 * 3) that have been receipted on 23.01.2010, where Posting Date = 23.01.2010.
You also have a record (quantity = 1250 * 1) that has been receipted on 26.01.2010. Posting date = 26.01.2010.
Now, in RSA3 & in PSA you can see more records than intended.
This is because you have before & after images. (ROCANCEL = X or blank).
ROCANCEL = X --> Before Image (record before change)
ROCANCEL = blank --> After Image (record after change)
This is a standard property of the extractor.
Now, we also have something known as BWVORG (Process Keys). Each process, i.e. creating a PO, Goods Receipt, Invoice etc.. have different Process Keys.
Creation - 001
Goods Rcpt. - 002
Invoice - 003
We can see that record 8, i.e. BWVORG = 002 (GR) has been modified on 26.01.2010.
That is why there is before image and after image.
Which one should be the correct posting date? 23.01.2010?
Normally in a Write optimized DSO, you will have all the records (before and after images & others as well).
I hope this helps.
Please let me know if otherwise. -
Hi all Thanks in Advance
I need help in Pivoting Data
SELECT ID,MONTH,COUNT FROM TABLE_PIVOT ORDER BY ID,MONTH
ID MONTH COUNT
10 10/01/2009 60
10 11/01/2009 80
10 12/01/2009 78
10 01/01/2010 81
10 02/01/2010 73
10 03/01/2010 84
10 04/01/2010 100
10 05/01/2010 107
10 06/01/2010 90
10 07/01/2010 0
10 08/01/2010 0
10 09/01/2010 73
20 10/01/2010 71
20 11/01/2010 76
20 12/01/2010 79
20 01/01/2011 79
20 02/01/2011 81
20 03/01/2011 88
20 04/01/2011 97
20 05/01/2011 87
20 06/01/2011 97I tried to pivot with below query
SELECT ID,
SUM(DECODE(to_char(month,'MM'),'01',count,0)) " Jan",
SUM(DECODE(to_char(month,'MMYY'),'02',count,0)) Feb,
SUM(DECODE(to_char(month,'MM'),'03',count,0)) Mar,
SUM(DECODE(to_char(month,'MM'),'04',count,0)) Apr,
SUM(DECODE(to_char(month,'MM'),'05',count,0)) May,
SUM(DECODE(to_char(month,'MM'),'06',count,0)) June,
SUM(DECODE(to_char(month,'MM'),'07',count,0)) July,
SUM(DECODE(to_char(month,'MM'),'08',count,0)) August,
SUM(DECODE(to_char(month,'MM'),'09',count,0)) September,
SUM(DECODE(to_char(month,'MM'),'10',count,0)) October,
SUM(DECODE(to_char(month,'MM'),'11',count,0)) November,
SUM(DECODE(to_char(MONTH,'MM'),'12',count,0)) December
FROM Table_PIVOT
GROUP BY ID
ORDER BY ID
ID Jan FEB MAR APR MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER
10 81 0 84 100 107 90 0 0 73 60 80 78
20 79 0 88 97 87 97 0 0 0 71 76 79I want output to display the column names with Month and Year like below
ID Oct-2009 Nov-2009 Dec-2009 Jan-2010 Feb-2010 ................... OCT-2010 NOV-2010 DEC-2010 JAN-2011 FEB-2011 ......
10 60 80 78 81 73 ...................
20 71 76 79 79 81
CREATE TABLE "TABLE_PIVOT"
( "ID" NUMBER,
"MONTH" DATE,
"COUNT" NUMBER
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('10/01/2009','MM/DD/YYYY'),60);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('11/01/2009','MM/DD/YYYY'),80);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('12/01/2009','MM/DD/YYYY'),78);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('01/01/2010','MM/DD/YYYY'),81);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('02/01/2010','MM/DD/YYYY'),73);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('03/01/2010','MM/DD/YYYY'),84);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('04/01/2010','MM/DD/YYYY'),100);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('05/01/2010','MM/DD/YYYY'),107);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('06/01/2010','MM/DD/YYYY'),90);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('07/01/2010','MM/DD/YYYY'),0);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('08/01/2010','MM/DD/YYYY'),0);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('09/01/2010','MM/DD/YYYY'),73);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('10/01/2010','MM/DD/YYYY'),71);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('11/01/2010','MM/DD/YYYY'),76);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('12/01/2010','MM/DD/YYYY'),79);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('01/01/2011','MM/DD/YYYY'),79);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('02/01/2011','MM/DD/YYYY'),81);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('03/01/2011','MM/DD/YYYY'),88);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('04/01/2011','MM/DD/YYYY'),97);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('05/01/2011','MM/DD/YYYY'),87);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('06/01/2011','MM/DD/YYYY'),97);
COMMIT;Hi,
user1849 wrote:
Any Sample code is appreciated
I didn't see any solution for following one in your linklI think Centinul was specifically referring to:
Help for a query to add columns
but other links from
SQL and PL/SQL FAQ
may help you more.
>
Re: How to pipeline a function with a dynamic number of columns?
Posted: May 9, 2006 2:58 PM in response to: Billy Verreynne Reply
Interesting stuff! It's going to take me awhile to digest it.
For what it's worth, I was trying to build a pivoting function that would take a MYTABLE table like this:
YEAR CITY X Y
2000 BAL 95 96
2000 BOS 101 101
2001 BAL 92 94
2001 BOS 101 101
2002 BAL 98 98
2002 BOS 98 99
2003 BAL 95 96
2003 BOS 105 104
and allow me to do something like:
CREATE VIEW MYPIVOT
AS
SELECT *
FROM TABLE (PIVOT(MYTABLE, [with other params]))
and get the following view MYPIVOT on the table:
YEAR BOS_X BOS_Y BAL_X BAL_Y
2000 101 101 95 96
2001 101 101 92 94
2002 98 99 98 98
2003 105 104 95 96
Where the number of distinct CITY values will vary over time. I am able to build the query I need dynamically, but since the CITY data values in the original table change, the columns are not necessarily static from invocation to invocation. Therefore I didn't want to just create a view using the dynamic SQL once, because it may need to be created next time I need to access the view. I wanted to be able to access the pivoted data on demand.A pipelined function is your best bet for that.
I couldn't do was be able to execute the query and treat it as a pipelined function, hence my original question.Sorry, I don't understand.
I'll dig into the code above to see if it does what I wanted, but if someone has a better suggestion on how to approach this, I'd be interested in hearing it.A completely different approach is String Aggregation , where you would get output like this:
YEAR TXT
BOS_X BOS_Y BAL_X BAL_Y
2000 101 101 95 96
2001 101 101 92 94
2002 98 99 98 98
2003 105 104 95 96Note that this output contains 6 rows and 2 columns. On the first row, year is NULL and txt=' BOS_X BOS_Y BAL_X BAL_Y'. You can do this is pure, static SQL, without knowing the number of cities in advance. -
How to display record with most recent date in sapui5?
Hi
I have a local json data with me, in which I have number of records.
And in each record I have an "AENDATE" as a date property.
Now I want to display the record with most recent date in the records.
How I can I do it......????????
Please help me with this.
Thanks
SathishHow about sorting your json model descending, and display only first (index:0) item?
-
Chart: amount (count) of records per month (and year). How?
I need to create a chart eventually. Can't get what formula to use. The data is:
1 | 15 Jan
2 | 20 Jan
25 | 14 Mar
26 | 16 Mar
28 | 20 Mar
The chart should show amount(count) of records per month(and year). So in this example:
Jan: 2
Mar: 3
Hm... totally lost. Any tips?To do this it would be best to add a column in which you isolate the month from the rest of the date information. Here's an example:
You may hide the Month-Isolated column if it impacts your presentation.
The Month-Isolated formula is: =IF(ISBLANK(B), "", (MONTH(B)))
The formula for the count in the Summary table is: =COUNTIF(Data Table :: $C, COLUMN())
Hope this gets you on your way.
Regards,
Jerry -
Finding the record with the latest date
Post Author: sconlon
CA Forum: General
Hi,I am using CR 8 with an Access database which has a table that holds (multiple) sales records for each of our clients. I want to create a report that lists only the latest sale from each client. I am thinking that I first need to group by client and then create a sub-report that prints the necessary details of sales record with the latest date of sale. It's this last bit that I cannot figure out how to do. Can anyone suggest a way of doing this?Many thanks,sconlonPost Author: Jagan
CA Forum: General
Charliy's suggestion if fine, and does require sorting and displaying in the group header/footer according to the sort order. In case it's not clear, when you print in the group header you are using the first record's data; when you print in the group footer you are using the last record's data (first and last within the group that is).
Personally, I'd group on the client have a group selection formula of:
{table.date_field} = maximum({table.date_field}, {table.client_id})
so that there's no date sort required as you'll only get one record per client group - assuming that each record has a unique date of course. I'd probably still suppress the details section and display in the group footer, but it wouldn't matter if you use the details section either.
I believe the benefit with the group selection formula is that any summary formulas, running totals etc. you use would only have the one record per client to work on, rather than including all of the suppressed records too. -
Hi! I am trying to find an app that with track everything that is done on my phone with times and dates? im not really woried about call usage and texts sent I need it to view what has been done - for example:
Messages received
Messages deleted
Facebook viewed
Messages viewed
Internet viewed and what?
I just have an issue with someone using my phone - I used to track this through double clicking the home button and roughly knowing in what order I had been on things but they have sussed this one!
Thank you!!No way to do that on a non-jailbroken iPhone. Why don't you just passcode protect your phone? That way no one but you can use it...unless they know your passcode.
-
Concept:
Every month i need to find the list of .rar files from the
E:/TempBackup directory from the different environments (remote desktop servers) and i need to delete the current month
.rar files alone from the respective (E:/TempBackup) directory. below is example files structure inside the
E:/TempBackup.
example:
zDROP_2014_08_31_Backups.rar
zDROP_2014_09_31_Backups.rar
zDROP_2014_10_31_Backups.rar
from the above list i need to delete the zDROP_2014_08_31_Backups.rar(current month) file alone and also logs should be capture for this deletion.
key words for this are zDROP and Current month and date.
i need a stored procedure for this concept. could you please help on this.Hello,
You can schedule an operating system task (Control Panel -> Schedule task) to either call a batch file or a PowerShell script.
Please read the following resources for examples:
http://social.technet.microsoft.com/Forums/windowsserver/en-US/61373719-fffb-4d94-bdbe-7d8ed8620b44/delete-filesfolders-on-remote-servers-using-powershell?forum=winserverpowershell
http://www.networknet.nl/apps/wp/archives/943
http://jeffwouters.nl/index.php/2011/10/powershell-script-to-delete-files-older-that-a-week/
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com -
Copy photos with info and data to a cd
I have Adobe Photoshop Album Starter Edition 3.2 and put in all the photos I had in my files. Then marked every single photo with information and data (a hell of work) and decided to make a backup copy on cd.
To my astonishment on the cd all the photos turned out to be completely unorganized and all the text I put below them were nowhere to be found!!!
Did I do something wrong, or is it not possible to get an organized cd with information using this edition of Photoshop?
Thanks in advance for your help.>I am trying tommove a block of pictures from my d drive over to photo shop
>3.0 and want to move more than one photo at a time.
I'm not sure what you mean by moving pictures from D: drive to PS 3... PSA
SE 3.2 is just a cataloging application. It doesn't actually store anything,
it just tells you where things are, or helps you to work with them.
>Or I can load them into photo shop from a CD.
It sounds like you just want to make sure the PSA SE knows that they are
there....
Essentially, you can just Click on the "Get Photos" button and choose the
source. Keep in mind that this will NOT physically move images and doesn't
have that ability like Photoshop Elements 5.0.
As to the DVD... it can track it depending on the video type. When you say
"Get Photos"... look to see if has detected it. If you see that it has and
offers to catalogue it for you, then you know that you're okay.
Cheers -
i have an iPad with apps and data already on it i just bought a mac how do i transfer the data from i pad to mac
here
1) Without connecting your iPad to your laptop, start iTunes. Click on Edit. Click on Preferences. Click on Devices. Check the box next to "Prevent your iPod etc. from automatically syncing." Click OK.
2) connect your iPad to your laptop and start iTunes.
3) When iTunes starts, right click on your iPad under Devices in the left column. Select Transfer purchases etc.
4) After it finishes transferring all your apps to your new laptop, right click on your iPad and select Backup your iPad.
5) After it finish backing up your iPad, right click on your iPad and select Restore etc.
6) After it finishes restoring, left click on your iPad , then click on the Apps tab on top, and check the box next to Sync Apps, then click on Apply below.
If everything on your iPad looks good after the sync, go back and click on Edit / Preferences / Devices and UN-check the box next to Prevent your iPod etc. The only other thing you may want to check is if your contacts, bookmarks, etc. are syncing correctly now. If not, go to the Info tab after connecting and make sure you indicate which features you want to sync with what sources. -
Seeing the month and date in the finder bar?
In the 'finder bar(?)' I have the day of the week and the time. Is there anyway to have the month and date there too? Instead of having to click on it and seeing it below?
Thanks, JordanYou can do this via the International preference panel.
Click on the Customize button next to the "Dates" section.
Select and copy the entire date there.
Then click on the "Customize" button next to the "Times" section. Make sure the "show" menu is set to medium. Click to the right of the Time so the insertion point is next to the current time, put a separater character such as "|" then past the date into the field.
Then close the window. That's it. -
Getting year, month and date
I am getting the current year, month and date as follows:
public void setDate(Date date) {
String strDate = "";
//year
Calendar cal = Calendar.getInstance();
cal.setTime(date);
strDate += cal.get(Calendar.YEAR);
//month
strDate += cal.get(Calendar.MONTH) + 1;
//date
strDate += cal.get(Calendar.DATE);
this.date = strDate;
}This gives me the date in teh format yyyymd.
i.e for Mar 5 2007, it returns 200735
How can it retrieve it in yyyymmdd format?
i.e. Mar 5 2007 must be 20070305use the function:
private String getTwoNumberFormat(int i){
if (i<10)
return "0"+i;
else
return ""+i;
}and then call
//month
strDate += getTwoNumberFormat(cal.get(Calendar.MONTH)+1);or use SimpleDateFormat :) -
I have updated my iPad mini to iOS 7.1.1 recently. After updated, it went wrong with time and date even I tried to restart it or set manual time/date or set auto time/date. How can I solve this problem?
Hello Phirum OL,
Here is an article that will help you adjust the date and time settings on your iPad:
iOS: Troubleshooting issues with date and time
http://support.apple.com/kb/ts3920
Learn the steps to take if your device has any of the following issues with the date and time.
Incorrect date or time
Wrong time zone being set automatically
Issues related to automatically switching with daylight savings time
Thank you for contributing to Apple Support Communities.
Cheers,
BobbyD -
HT1807 With cellular and Data networks off, can I still receive and make calls on my 4s
With cellular and data networks off, can I still receive and make calls.
Old guy, still learning to use cell phone. Going out of US and don't want to have big charges when I return. I do want to have my phone on for emergencies and I plan to get international cell. and messaging.
-
Dyamic execution of report for every month and data through mail.
Dear Friends,
We are using ECC6.00 With EHP4. My requirement is to send the list of pending notifications with the list details as appearing in transaction QM10. Every month i am supposed to change the from date and to date for example 01.07.2010 to 31.07.2010 for the month July.
How can i make system calculate the from and to date for every month and send mail.
I can schedule the job using SM36 but how to make system calculate the from and to date dynamically for every month. i.e., for august system should calculate date 01.08.2010 to 30.08.2010 automatically as the next month is reached.
Experts help required.
Regards,
M.M1. You need to create a variant.
2. In this blank out the date and give all the required values which will filter for the Pending nofitications like notificaiton type, status, etc.
3. Then click save.
4. When you click save it will give you an option to save as variant.
5. Now in the Variant Attributes screen give the variant name/meanting
6. In the below you will get a "objects for selection screen)
7. In the same you will get the filed name calle d" notification date"/
8. Here Move the curson to the righ side you will find the selection variable, change to D-Dyanamic date calcuation and after that right side you will see one more column for the name of variable(input using only f4)
9. Here press f4,
10. then ypou get a pop up for selection varaible. there first Put "I: for current date and also 'I" for hte Current date +/- ??? days
in this give 30 days.
11. You can also use other function her.e
Now once the variant is created then you have to schedule a job for this program + variant in the sm36 and in the distribution list
you need to mention the email
check and let me know for the feedback
reg
dsk
Maybe you are looking for
-
TAKE HOME TEST i need help with
Chapter 11 ? Arrays Continued Test CAN ANY1 HELP ME ANSWER THIS?? 1. A hair styling salon provides many services, The HairSalon class contains a String field to hold the type of service, a double to hold the price for that service, and a double to ho
-
Accented characters again, this time in WEB module
Hi, today I made an amazing discovery: even if the language and user interface of LR (2.0) is set to German, there is no provision to deal with accented characters (üöä) in the web galleries. These are taken directly into the generated html files. So
-
Lightroom 5.2 RC Printing Issue
I am using the 5.2 RC and an Epson Sylus Photo R2000 printer. I am trying to print 4X6 prints and no matter what I do I looks like it is trying to print the image on 8.5X11 paper so I get fragments of about 4 4X6 paper. I have an example posted wit
-
Help getting report to execute from URL
Hello, I'm able to generate a URL to access a report with parameters specified; however, the user still has to click 'Apply' to run the report. Is there a way to format the URL such that the report is executed? Thanks! Jess http://reports.myco.com/_v
-
System Specifications for HR/Payroll
Was trying to determine some minimum system specifications (i.e what is needed) to install HR/Payroll modules. Does not have to be specific to O/S, looking for sizing information. High level information would be more than enough.