Group by with date
Hi !
I need help (sorry for my english) :
my sql :
SELECT ligne,TO_CHAR(TO_DATE(DATE_VAL),'DD/MM/YYYY') DATE_VAL,COUNT(*)
FROM VALID, MIS, SERV
WHERE id_mis=id_mis_val AND id_serv=id_serv_vmis
AND DATE_VAL >= '04/06/2007' AND DATE_VAL < '06/06/2007'
AND LIGNE_VSERV = 923
GROUP BY date_val
the result :
900 04/06/2007 1
900 04/06/2007 2
900 04/06/2007 1
900 04/06/2007 1
900 04/06/2007 1
900 05/06/2007 1
WHY ?
I want the result like that :
900 04/06/2007 6
900 05/06/2007 1
How to make that ? please help!
Thanks a lot
Why not...?
SQL> create table t(c1 date,cnt number);
Table created.
SQL> insert into t
2 values(sysdate,10);
1 row created.
SQL> insert into t
2 values(sysdate,15);
1 row created.
SQL> insert into t
2 values(sysdate-12,15);
1 row created.
SQL> insert into t
2 values(sysdate-12,15);
1 row created.
SQL> select to_char(c1,'ddmmyyyy') c1,sum(cnt) sm
2 from t
3 group by to_char(c1,'ddmmyyyy');
C1 SM
02062007 30
14062007 25
Message was edited by:
jeneesh
Forgot to refresh...
Similar Messages
-
Group by with date range.
Hi,
I am looking for effective usage of Group by against date range.
I have a transaction table as below.
Date customer_no amount_paid
01-Dec-13 001 500
02-Dec-13 001 360
09-Dec-13 001 200
02-Nov-13 001 360
09-Nov-13 001 200
02-Nov-13 001 360
09-Oct-13 001 200
02-Oct-13 001 360
09-Oct-13 001 200
02-Sep-13 001 360
09-Sep-13 001 200
............... etc.
I would like to see sum(amount_paid) by past date ranges 1-30 days, 31-60 days, 61-90 days.
Below are expected results.
Customer Duration amount_paid
001 1-30 980
001 31-60 450
001 61-90 1200
002 1-30 300
002 31-60 490
002 61-90 320
003 1-30 450
......................etc.
I have to group by customer no and date range (1-30, 31-60, 61-90..etc).
Can someone help me getting query for this.
Thanks...
Sreeram.SQL> with t
2 as
3 (
4 select to_date('01-Dec-13', 'dd-Mon-rr') dt, '001' customer_no, 500 amount_paid from dual
5 union all
6 select to_date('02-Dec-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
7 union all
8 select to_date('09-Dec-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
9 union all
10 select to_date('02-Nov-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
11 union all
12 select to_date('09-Nov-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
13 union all
14 select to_date('02-Nov-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
15 union all
16 select to_date('09-Oct-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
17 union all
18 select to_date('02-Oct-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
19 union all
20 select to_date('09-Oct-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
21 union all
22 select to_date('02-Sep-13', 'dd-Mon-rr') dt, '001' customer_no, 360 amount_paid from dual
23 union all
24 select to_date('09-Sep-13', 'dd-Mon-rr') dt, '001' customer_no, 200 amount_paid from dual
25 )
26 select customer_no
27 , ((grp_val - 1) * 30) + 1 start_val
28 , grp_val * 30 end_val
29 , sum(amount_paid) amount_paid
30 from (
31 select dt
32 , customer_no
33 , amount_paid
34 , ceil(sum(dt_interval) over(partition by customer_no order by dt)/30) grp_val
35 from (
36 select dt
37 , customer_no
38 , amount_paid
39 , nvl(dt - lag(dt) over(partition by customer_no order by dt), 1) dt_interval
40 from t
41 )
42 )
43 group
44 by customer_no
45 , grp_val
46 order
47 by grp_val;
CUS START_VAL END_VAL AMOUNT_PAID
001 1 30 560
001 31 60 760
001 61 90 920
001 91 120 1060
SQL> -
Keep Group headings with data - control your page breaks
Trying to keep the group heading with the appropriate transaction information. Currently, get a group heading at the bottom of a page and then the transactions print on the next page. Difficult to determine what the transaction information is without the appropriate group headings displayed. The amount of transaction data is not static, it varies from page to page. Some of the reports can be close to 100 pages. Please advise.
Hi Kim,
You can use the option u201CNew Page Afteru201D in Section Expert for Group Footer section so that the new group Header will display on the next page.
Regards,
Alpana -
Query to group values with date
Dear all,
I have a table tdate with 13 columns with one column named trandate
with value like "11/07/2008 18:00:19"
NOw I want to retrieve values from the table like
select count(*) from trandate where where ttype = '081' and T_FILE like 'monT%';
I want to count the records for every month like
jan-2009 - 120 (120 is the number of records satifying the above condition and belong to the period jan 2009 (derived from trandate column)
feb-2009 - 150 (150 is the number of records satifying the above condition and belong to the period feb 2009 (derived from trandate column)
How can i rewrite the query
Thanks
Kai
Edited by: KaiS on Feb 1, 2011 4:23 AMSomething like this?
SELECT TO_CHAR(trandate,'mon-YYYY') AS trandate
, cnt
FROM
SELECT trandate
, COUNT(*) AS cnt
FROM trandate
WHERE ttype = '081'
AND t_file LIKE 'monT%'
GROUP BY trandate
ORDER BY 1
)If that doesn't work out then please post:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details. -
Purchasing Group Relation with data or setting
Dear All,
Can anyone please advice me if there is anything we should check after new purchasing group have been created?
I have just created 15 new purchasing group, some of the group code is being replaced by this new group code.
Thank you very much,
Regards,
Chee WeeHi
If you are creating a new purchaing group then it is not at all a problem because it is a free floating entity. You don't have to assign to any other entity. But if you are deleting any then you need to consider previous transaction in which that purchasing group is used. If there is any open transaction then in that you need to give new purchasing group. Then reports for old transaction may also give inconsistancy.
Regards
Antony -
Count(*) with group by max(date)
SQL> select xdesc,xcust,xdate from coba1 order by xdesc,xcust,xdate;
XDESC XCUST XDATE
RUB-A 11026 01-JAN-06
RUB-A 11026 05-JAN-06
RUB-A 11026 08-JAN-06
RUB-A 11027 10-JAN-06
RUB-B 11026 02-JAN-06
RUB-B 11026 08-JAN-06
RUB-B 11026 09-JAN-06
RUB-C 11027 08-JAN-06
I want to make sql that result :
XDESC COUNT(*)
RUB-A 2
RUB-B 1
RUB-C 1
Criteria : GROUPING: XDESC XCUST AND MAX(DATE)
bellow mark *** that was selected in count.
XDESC XCUST XDATE
RUB-A 11026 01-JAN-06
RUB-A 11026 05-JAN-06
RUB-A 11026 08-JAN-06 ***
RUB-A 11027 10-JAN-06 ***
---------------------------------------------------------COUNT RUB-A = 2
RUB-B 11026 02-JAN-06
RUB-B 11026 08-JAN-06
RUB-B 11026 09-JAN-06 ***
---------------------------------------------------------COUNT RUB-B = 1
RUB-C 11027 08-JAN-06 ***
--------------------------------------------------------COUNT RUB-C = 1
Can Anybody help ?
I tried :
select xdesc,max(xdate),count(max(xdate)) from coba1 group by xdesc
ERROR at line 1:
ORA-00937: not a single-group group function
ThankThis one is duplicate. see the following link
Count(*) with group by max(date)
Thanks -
Query For Retrieving Data With Date and grouping
Hi Guys
I am having a hard time to figure out the sql query.
I have a table with data. Below is the illustration.
date location item description
1 jan 14 A apple desc1
2 jan 14 A apple desc2
3 jan 14 B apple desc1
4 jan 14 B apple desc2
1 jan 14 A orange desc1
2 jan 14 A orange desc2
3 jan 14 B orange desc1
4 jan 14 B orange desc2
My question it how to get the latest date on each location and item along with the description field
This is the result I want
date location item description
2 jan 14 A apple desc2
4 jan 14 B apple desc2
2 jan 14 A orange desc2
4 jan 14 B orange desc2
Thanks.provided it a datetime/date field you've for date you can do this
SELECT [date],location,itemdescription
FROM
SELECT [date],location,itemdescription,
ROW_NUMBER() OVER (PARTITION BY location ORDER BY [date] DESC) AS Rn
FROM table
)t
WHERE Rn = 1
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Post Author: tadj188#
CA Forum: Formula
Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
Background:
1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using subreports. A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report with their respective detail lines). I had multiple subreports and each subreport became one union.
Created and tested, already:
1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
Issue:
1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
Other Ideas Appreciated:
1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
Thank you.
Tadjexport all image of each page try like this
var myDoc = app.activeDocument;
var myFolder = myDoc.filePath;
var myImage = myDoc.allGraphics;
for (var i=0; myImage.length>i; i++){
app.select(myImage[i]);
var MyImageNmae = myImage[i].itemLink.name;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
app.jpegExportPreferences.exportResolution = 300;
app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
alert(myImage[i].itemLink.name) -
How to move tables with data from one client to another
Hello friends
I have 2 clients 001 and 002.
I have created a table with lots of data on client 001.
I have to get the same table on 002 also with the same data.
Is there an easier way of transfering this data from one table to another?
I would appreciate any feedback on this.
I know that mappings etc., can be done using the export and import of tpz file. So I want to know if there is any similar thing to transfer a table with data.
THanks
Ramhi
thanks for the response
We are working on a sandbox system for demo purpose.
Actually we have two different group of people using two different clients created on the same server.
Our group is using client 001 and another group is using client 002.
We don't want the changes that one group does to the table to affect the other.
Our group has created a z-table and have entered considerable amount of data.
However, the other group also need to create the same table with the same data.
So to avoid double work, we were trying to see if there is a way to copy the table with data created on 001 to 002.
Any suggestions / feedback will be greatly appreciated.
Thanks
Ram -
Pdf form for data from another form with data, xml or pdf, tables not expanding
Sir,
I am using Adobe Acrobat 9 Pro and LifeCylce to do these forms. I have made several subforms for a Risk Assessment for the mission they fly. I have also made up another form with tables that would connect with each subform data. This form also will give me and others a % of the values received from the data to help us with seeing problem area towards Safety.
I am able to connect the data to the form from the Risk Forms but when I go and add another group of data it over writes the data that was already in the data collection form. The tables are dynamic and able to expand with the generated data but when I compile several Risk Forms, xml. data into one single data group, the receiving tables will not except this data. To compile the data I am in Acrobat and using the form-manage form data-merge data to spreadsheet than enter as a report that is xml. Still not working. I also tried to save the form, with data already in the tables, and then opened it again and add data to it, it will over write the existing data in the form. This form does work great with the generated data in LiveCycle.
Any suggestions???Thanks Paul
Did as you said and for each subform binding tab made sure I have "Repeat subform for each data item" checkbox and still no change when I add the data.
I even tried to combine the xml data and that file just has the main page and not the data pages. just another problem that is happening.
Any other suggestions on this expanding tables and receive single forms one at a time.
Bill -
Why can't I be in a group chat with an android user?
I have the iphone 5 and I am not able to participant in group chats if there is an android user involved. I will not even see the messages that are sent. For example, there is a group chat with another iphone 5 user, an iphone 4s user, and an android user. I am in the chat, as other parties can see my number, but I do not receive any texts from the group.
Because you are using lightroom, whether cs5 supports that camera model or not is irrelevent, unless you open or place the raw file itself into photoshop.
Lightroom does not send a raw file, it sends a tiff or psd (Jpg is also an option if you use a secondary editor) file to photoshop. Odds are greater that lightroom 4 does not support your camera.
Adobe has a list of camera models that each version of lightroom and camera raw support. It will tell you whether you are up to date, need to do an update. If they are not an option then you can use the dng converter or purchase a newer version of lightroom. -
How to use aggregate function with Date
Hi All,
I have a group of date from that is it possible to Max and Min of date.
I have tried like this but its errored out <?MIN (current-group()/CREATION_DATE)?>.
I have also tried like this but it doesnt works
<?xdoxslt:minimum(CREATION_DATE)?>
Is it possible to use aggregate function with date values.
Thanks & Regards
SrikkanthHi KAVI PRIYA,
if date is not in cannonical format, how can we change it in BI publisher, then how to calcualte minimum and as well as maximum.
please advise me,
Thanks,
Sri -
Payment Medium Workbench - Group by Posting Date
I have made a medium format with DMEE Engine but it doesn't work as I would like.
I want to have a file with all items group by posting date (subtotals group by posting date, no depends on vendor).
I have 2 leveles:
- Level 1: Repetition Factor 1 and Key Field FPAYP-FAEDT (Posting Date)
- Level 2: Repetition Factor 999999 and Key Field FPAYP-DOC2R (Document unique key)
However when I execute F110 transaction it generates different files, WHY?
One file per vendor and posting date, but I WANT TO HAVE A UNIQUE FILE.
Example
Vendor Posting Date Ammount
ITEM 1: xx 15/10/2007 100
ITEM 2: xx 15/10/2007 200
ITEM 3: yy 15/10/2007 300
ITEM 4: xx 21/10/2007 400
ITEM 5: zz 21/10/2007 500
Output (wrong)
FILE1:
15/10/2007
xx 100
xx 200
300
FILE2:
15/10/2007
yy 300
300
FILE3:
21/10/2007
xx 400
400
FILE4:
21/10/2007
zz 500
500
Output (ok)
FILE1:
15/10/2007
xx 100
xx 200
yy 300
600
21/10/2007
xx 400
zz 500
900
Thanks in advanced!Ok, the problem has been fixed.
The repetition factor for level 1 (Posting Date) should be 9999999 instead of 1, beacuse it refers to input data and it doesn't refer to output data.
We can have differents posting dates in input data, but we want to have a unique line by posting date in output data.
Regards! -
Fill the LOV with data during the execution
Hi
I am using Oracle 10g
I want to ask please if there is a way to fill the LOV with data during the execution
so can I change the query specified in LOV wizard during the execution and get a new record set according to the value in the text boxes
thank you for helpYou can use the SET_LOV_PROPERTY built-in to change the record group of the LOV and to create a new record group you can use the CREATE_GROUP_FROM_QUERY built-in.
it will be something like this.
RG_ID := FIND_GROUP('<record group name>');
IF NOT ID_NULL(RG_ID) THEN
DELETE_GROUP(RG_ID);
END IF ;
RG_ID := CREATE_GROUP_FROM_QUERY('<record group name>', '<your SQL statement here>');
POP_GROUP := POPULATE_GROUP('<record group name>');
SET_LOV_PROPERTY('<LOV name>', GROUP_NAME, '<record group name>');Use the online help for more information about these built-ins.
Tony -
Warning: There is no reporting group defined with a purpose of iRecruitment
Hi,
When i try to generate the offer letter in iRecruitment, i am getting the warning: There is no reporting group defined with a purpose of iRecruitment in "Enter compensation" Screen. However i am able to generate the offer letter,preview and submit the offer letter. I have referred the Article [ID 1168832.1] in oracle support. It suggest me to give the Temporary Directory file name using XML Publisher Administrator , but still the Warning appears.
STEPS
The issue can be reproduced at will with the following steps:
1. From Vacancy Search page, select applicant.
2. Create Offer: Enter Basic Details.
3. Warning: There is no reporting group defined with a purpose of iRecruitment for this business group.
4. Review page.
Version Details: Oracle Applications : 12.1.2
But still the offer letter is generated.
Can anyone advice me to over come this warning
Regards
SurayshI have the same behavior too. Looking at the iRecruitment implementation guide, I see reporting groups defined there.
1) Select your HRMS Superuser responsibility
2) Go to Total Compensation : General Definitions : Additional Setup : Reporting Groups
If you see no data, it's likely you have ... no reporting groups.
I think this time the error is pointing you in the right direction.
I hope this helps.
Maybe you are looking for
-
Snow Leopard has ruined my browsers
I upgraded from Leopard to Snow Leopard a few days ago, and ever since my internet browsing has been crippled. I use Google Chrome but the following problems persist across all browsers: - Websites randomly won't load, I'll just get the 'Oops! Google
-
"Recovered" CR2 files will not open in Photoshop CS6
My son recently completed the National Three Peaks Challenge. Regrettably, having taken loads of pictures, he discovered that one of the CF cards was corrupt. He and his fellow climbers have now paid a company (a considerable sum) to recover these ph
-
Creative Cloud Crashes When I Plug In a USB Drive
My problem is that Adobe Creative Cloud application crashes every time I plug in a USB drive. My computer is Windows 7 64-bit. A brief history: 1. I signed up for Creative Cloud and started to download and install the Creative Cloud desktop applic
-
One Time Vendor/Customer Accounts
Hi All, Can anybody explain the part in quotes. For all customers or vendors with whom you rarely do business, a special customer and a special vendor master record should be created. Those master records are for One-Time-Accounts. "In contrast to ot
-
How to copy the ringtone of my second pc to iPhone?
Hello, I tried to copy the ringtone of my pc to my friend's iPhone. But when I try to sync, message appeared that if I perform this, all ringtones of my friend's iPhone will be replaced with my pc's ringtone. There are already many ringtones in my fr