help with this group of
Hello
I need your help to make a group in a query (for ORACLE 11 g) for some columns and a particular column, get the latest (or value of that column) it's my table example:
CODE | MOBILE | AMOUNT | COUNTRY | RECORD_DATE |
---|---|---|---|---|
1000 | 99999999 | 10 | U.S.. | 18 JUNE 14 |
1000 | 99999999 | 5 | Italy | JUNE 13, 14 |
2000 | 99999999 | 20 | France | 16 JUNE 14 |
2000 | 88888888 | 3 | Germany | 17 JUNE 14 |
2000 | 88888888 | 11 | France | 14 JUNE 14 |
1000 | 88888888 | 32 | Canada | JUNE 10, 14 |
So my query result should make a 'group', CODE, MOBILE, and the AMOUNT of MONEY and give the latter country registered in this form:
CODE | MOBILE | AMOUNT | COUNTRY |
---|---|---|---|
1000 | 99999999 | 15 | U.S.. |
2000 | 99999999 | 20 | France |
1000 | 88888888 | 32 | Canada |
2000 | 88888888 | 14 | Germany |
Is just an example, I can make the query and group by statement, but I can't show just the last country (though I think that in the recent record of column RECORD_DATE).
Can you help me with this pls? I don't know much about oracle 11 g
Thank you much in advance.
Best regards
Mauro
Hi, Mauro,
So, you don't want to MAX (record_date); you want to the country which is on the same line as the MAX (record_date); Isn't it?
This looks like a job for the fucntion LAST aggregation.
Since I have not phew copy your table, I'll use scott.emp (which is probably on your system) to illustrate.
SELECT deptno, job
The SUM (sal) AS total_sal
MIN (ename) DUNGEON (DENSE_RANK LAST ORDER BY hiredate)
AS most_recent
FROM scott.emp
GROUP BY deptno, job
ORDER BY deptno, job
;
Output:
DEPTNO JOB TOTAL_SAL MOST_RECENT
---------- --------- ---------- -----------
THE 10 1300 MILLER CLERK
10 MANAGER 2450 CLARK
10. PRESIDENT KING 5000
20 ANALYST SCOTT 6000
20 CLERK 1900 ADAMS
20 MANAGER 2975 JONES
JAMES CLERK 30 950
30 MANAGER 2850 BLAKE
30 SELLER 5600 MARTIN
What happens if one is be a tie for the most recent line, i.e. If the MAX (record_date) in a group we produce 2 or more lines, with different countries?
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.
If you change the query at all, post your modified version.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://community.oracle.com/message/9362002#9362002
Tags: Database
Similar Questions
-
help with this thread using oracle 7.3
Dear expert;
On this thread, I am using
but I'll need help more with additional information in this regard. see examples of data below
Hello experts.
I use oracle 7.3. Therefore, I have the sample data below
create the table table_one
(
req_week varchar (1000).
Username varchar (1000).
sale number (30),
place varchar (1000).
break_sales number (30)
);
insert into table_one values ("week 1", 'John', 100, "NY", 2 ").
insert into table_one values (' week 1', 'Chris', 20, "TX", 3 ')
insert into table_one values ("week 1", "Melissa", 80, 'GOES', 4 ')
insert into table_one values (' week 2', 'Katy', 40 'SC', 1 ")
insert into table_one values (' week 2', 'Angle', 10, 'NC', 2 ')
insert into table_one values (' week 2', "Vick", 30, 'CA', 3 ')
insert into table_one values (' week 3', 'Zack', 60 'CA', 1 ")
insert into table_one values (' week 3', 'Deb', 60 'NM', 2 ')
insert into table_one values (' week 3', 'Antoine,"60,"TX", 3 ')
necessary results
I need the top 2 sales in a place a week
expected results
req_week username place sales
Week1 John 100 NY
Week1 Melissa 80'S
Semaine2 Katy 40 SC
Semaine2 Vick 30 CA
Semaine3 Zack 60 TX
Semaine3 Deb 60 NM
Note, in this particular case, if there is equality in sales, then use the break_sales column as a case. The break_sales was never a tie... it is so far the query and it does not work as expected
SELECT d.req_week, d.username, d.sales, d.place FROM nikeus_report.dbo.table_one d , nikeus_report.dbo.table_one o WHERE d.req_week = o.req_week AND d.sales <= o.sales GROUP BY d.req_week, d.username, d.sales, d.place HAVING COUNT (*) <= 2 ;
Any help is appreciated. Thank you
Hello
It seems that your existing query is very good, he's going; Just add the conditions for breaking in the WHERE clause:
SELECT d.req_week
d.username
d.sales
d.place
FROM table_one d
table_one o
WHERE d.req_week = o.req_week
AND (d.sales< > >
OR (d.sales = o.sales
AND d.break_sales > = o.break_sales
)
)
GROUP BY d.req_week
d.username
d.sales
d.place
HAVING COUNT (*)<=>=>
ORDER BY d.req_week
COUNT (*)
;
Thanks for posting the CREATE TABLE and INSERT statements; that really helps.
-
Is there a default value for the color management in PSE10? Beautiful photos from iPhoto, but blur with elements. I need help with this before as I consider that the upgrade to PSE13 and beyond.
Printing which forms an angle seems ok, but one that is horizontally seems faded, incomplete.
I was wondering if I saved a layer somewhere and set it as a default value.
If you group the layers, you will be left with a single layer, thus spreading your concern.
Suggest that you do the following:
- Make sure you have the latest drivers for your printers
- Reset the default preferences.
Hold the Alt, Ctrl + Shift keys when you click the icon to open the items. When asked if you want to delete the settings file, say Yes.
Items nearby and let regenerate the file.
-
Help with this
Help with what?
-
[Error number: 0x8024400A] Need help with this error... I reinstalled XP SP1 and I can't get an automatic update that's simple to install, just get this error at each time HHHHEEEELLLPPPPP! Thank you
I had the same problem. But finally found a solution. If your listing is similar to mine, then keep. XP Media Center Edition 2005 (sp2). AMD Athlon 64 x 2 Dual-Core, HP a1630n desktop computer.
Go to the HP website, search for sp37394-XP sp3 Upgrade utility Microsoft for systems equipped with AMD processors.
I had the same 0 x 80240036, 0x8024400a error, but realize my problem was really get manually downloaded sp3 and installed without continue loop crashing and not error messages.
-
Where Iget can help with this message? «Adobe Acrobat Reader DC could not open (my file.xls) because it is not a type of supported file or because the file has been damaged (for example, it was sent as an attachment to e-mail and has not been correctly decoded).» I don't know where to go or how to solve this problem. It started to happen after I went to the office 356 and uses Windows 10.
Please see the troubleshooting provided in this KB doc steps: fix damaged document error when opening PDF files
Let us know if you still experience the problem.
Kind regards
Meenakshi
-
Installation update for creative cloud can never exceed 2%, which means that I cannot have access to Premiere Pro. Can anyone help with this? I need urgent access to Premiere Pro, so I can return videos to my clients.
Check your (win) Task Manager or activity (mac) for a suspended adobe monitor helps the process that you can complete.
-
Dialog box that says ' Creative Cloud Installer wants to make changes. Type your password for this purpose"- I type my password for Adobe ID (creative cloud), but it will not accept it. who should I go for help with this query?
It does not ask the cloud your computer admin password password!
-
Illustrator draw android app says that it requires 4.3. I have a viking RCA pro 10.1 which is 5.0, but it says that my device is not compatible. Can anyone help with this?
HI JBlessed,
What is a Tablet? Because the draw is not yet supported on Android tablets.
Sue.
-
I'm trying to load another computer with CC, I was told that I have to disable my PC mine. I did once before and lost a lot of my images from LR, suggestions on this please.
I do the LR back ups system too.
Thank you very much
PAM
Hi goaliemom
There is no way to disable CC products. When you enable a CC product on another computer, simply connect to Creative Cloud.CC will ask you if you it will activate on more than 2 computers.
I've done it before and I lost many of my images that were on LR. No matter WHAT HELP with this please
On the computer on which you will see that your images are not displayed?
Catalog check the most recently used file > open recent in Lightroom
Try opening a recent backup made on your newly added computer
~ Assani
-
Get error 207 trying to download creative Cloud and someone please help with this problem, thanks in advance please.
Please refer to
-
Accidentally, I bought the Mac in December and contacted support which helped me to get the right version installed, but now the PC version is not in my account downloads and I need to add it to a new computer. I don't know how to get help with this. I don't remember how I got the PC version, I think I have access to my computer remotely and she sent, but I can't find any record of it.
Since this is an open forum, not Adobe support... you must contact Adobe personnel to help
Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)Creative cloud support (all creative cloud customer service problems)
http://helpx.Adobe.com/x-productkb/global/service-CCM.html -
I had to update my windows computer and you can no longer open Photoshop cs2. trying to find help with this new system is not easy to use to put it kindly. I downloaded the program and don't have the available key. I tried to sign in but where.
For Photoshop CS2 activation has been reprocessed, so your original drive and the serial number does not work.
As an owner of CS2, Adobe has a copy without activation and serial number, to which you are entitled.
The serial number is to the right of the download link for Windows. You'll need this one, not your old number.
Get them here: download Acrobat 7 and CS2 products
-
I just installed 5 Lightroom, but cannot import photos, there is no option to import anywhere. Download pop up saying error trying to change modules.
I had this with the trial, then I bought the license and still happens. Help with this?
-
Need help with this gallery of xml!
I have build a gallery but its very simple... There are pictures of the xml file.
I have attached all the zip files.
I just want two things if anyone can help.
first of all when I press the next button, he's going to the next image, but without effect. It just displays the following image... I want to incorporate the effect of dragging when the image is changed to another.
and secondly, I want to use the AutoPlay feature.
Once swf starts images came one by one with a vertical drop of a few seconds.
Thanks in advance... I really need help with this..!
For the look of sliding effect using the actionscript class Tween. Allows you to create motion tweens using the code. The example below will be tween property _x of the instance named anObject from 0 to 300 in 3 seconds...
import classes before using
Import mx.transitions.Tween;
Import mx.transitions.easing.Regular;TW var = new Tween (anObject, "_x", Regular.easeIn, 0, 300, 3, true);
To implement an enforcement function auto you need to import all the images first, in the order, then you will need to use form any controlled timer, such as setInterval (with clearInterval not to need) in order to have things turn on automatically by some part-time
Maybe you are looking for
-
CD will not eject - Pavilion 6400 - no manual eject hole
Do not eject a cd of my Pavilion, 6400, which doesn't have a manual eject hole to stick a paper clip in. Clicking on eject on the computer of the road yields only noise and a failure message. Suggestions please?
-
Computer will not remain in standby mode.
I have a computer with Windows XP, about 5 years old who often will not remain in standby mode. After 30-45 seconds it starts again and the display shows again the office. Does anyone have a suggestion/recommendation what to do about it? Thanks, any
-
Hi and thanks for your support. The lifecam 3000 is ideal for photography, but I can't find a way to change the settings for audio, and also, I have only the settins wmv for video. I search the Web for a program that can do both, but with no good res
-
Security failure updades for Vista, but others have been installed.
I could not install new updates of swecurity for Vista, AThey fail whenever I try to install them, other updates are installed without problem.
-
KeyUp() in os 4.5 and 4.6
Hello In my code, I used keydown() and keyup() methods implement the keylistener, in 4.7 and 5.0, but odd in 4.6 and 4.5:keydown() is called while keyup() is not invoked by the same key code! then I put the keyup() in the keyDown() method, it works.