grouping lines and filtering year max for each group
Hello
I have a table called species_test (ddl):
CREATE TABLE species_test)
number of year_reported (4.0).
taxon_name VARCHAR2 (255),
Site_ID number);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1995, 'fish', 25);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1995, 'fish', 25);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1994, 'fish', 25);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1995, ' eel long fin ', 25);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1995, ' eel long fin ', 25);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1995, 'fish', 26);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (2000, 'fish', 26);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (2000, 'fish', 26);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1995, 'koura', 26);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1985, 'fish', 27);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1995, 'fish', 27);
INSERT INTO species_test (year_reported, taxon_name, site_id) VALUES (1995, 'fish', 27);
What I want to do, is to display the names of the unique species for each site_id and filter by the maximum year_reported for output looks like:
----------------------------------------------------------------------------
YEAR_REPORTED TAXON_NAME SITE_ID
Smelt of 1995 25
eel long 1995 25 fin
Smelt 2000 26
1995 koura 26
Smelt of 1995 27
---------------------------------------------------------------------------
I tried this query:
Select year_reported, taxon_name, site_id
of species_test
Year_reported group, taxon_name, site_id
with year_reported in (select max (year_reported)
of species_test
Year_reported group, taxon_name, site_id);
But this is not correct.
What I want to do, is to display the names of the unique species for each site_id and filter by the maximum year_reported for output looks like:
Try this:
with q as)
Select site_id, taxon_name, year_reported,
ROW_NUMBER () over (partition site_id, taxon_name
year_reported desc order) rn
of species_test)
Select site_id, taxon_name, year_reported
q where rn = 1
order by site_id, taxon_name
SITE_ID, TAXON_NAME, YEAR_REPORTED
25, long eel fin, 1995
25, smelt, 1995
26, koura, 1995
26, smelt, 2000
27, smelt, 1995
Tags: Database
Similar Questions
-
SQL query to search for the line that contains the identifier for each consecutive group
Hello
I'm on 11.2.0.3 Enterprise Edition.
I have a strange request here - do not know if this is possible without going to procedure...
Given these data of the sample:
create table test_status ( status varchar2(10), revision_id number, revision_timestamp timestamp); insert into test_status values ('PROPOSED', 1, systimestamp); insert into test_status values ('PROPOSED', 2, systimestamp); insert into test_status values ('PROPOSED', 3, systimestamp); insert into test_status values ('ACTIVE', 4, systimestamp); insert into test_status values ('ACTIVE', 5, systimestamp); insert into test_status values ('PROPOSED', 6, systimestamp); insert into test_status values ('PROPOSED', 7, systimestamp); insert into test_status values ('ACTIVE', 8, systimestamp); insert into test_status values ('ACTIVE', 9, systimestamp); insert into test_status values ('FINISHED', 10, systimestamp); insert into test_status values ('FINISHED', 11, systimestamp); insert into test_status values ('FINISHED', 12, systimestamp);
Gives me:
SQL> select * 2 from test_status 3 order by revision_id; STATUS REVISION_ID REVISION_TIMESTAMP ---------- ----------- ----------------------------- PROPOSED 1 25-SEP-14 04.49.47.954000 PM PROPOSED 2 25-SEP-14 04.49.47.962000 PM PROPOSED 3 25-SEP-14 04.49.47.966000 PM ACTIVE 4 25-SEP-14 04.49.47.969000 PM ACTIVE 5 25-SEP-14 04.49.47.972000 PM PROPOSED 6 25-SEP-14 04.49.47.976000 PM PROPOSED 7 25-SEP-14 04.49.47.979000 PM ACTIVE 8 25-SEP-14 04.49.47.982000 PM ACTIVE 9 25-SEP-14 04.49.47.987000 PM FINISHED 10 25-SEP-14 04.49.47.991000 PM FINISHED 11 25-SEP-14 04.49.47.996000 PM FINISHED 12 25-SEP-14 04.49.48.000000 PM 12 rows selected. ws selected.
I want to get this result:
STATUS REVISION_ID REVISION_TIMESTAMP ---------- ----------- ---------------------------- PROPOSED 3 25-SEP-14 04.49.47.966000 PM ACTIVE 5 25-SEP-14 04.49.47.972000 PM PROPOSED 7 25-SEP-14 04.49.47.979000 PM ACTIVE 9 25-SEP-14 04.49.47.987000 PM FINISHED 12 25-SEP-14 04.49.48.000000 PM
Then query the table ordered by Revision_Id, I would get the line containing the highest revision for each consecutive group of status values. I am able to get the line containing the highest revision for each separate status, value, but I can't deal with the scenario where a state value reappears later. In the case of the real world, it is a workflow and I need to take into account the fact that an element through the workflow may be redirected to the back front she proceeds forward again.
Hope it makes sense.
Thank you
John
Hi, John,.
John OToole (Dublin) wrote:
Hello
I'm on 11.2.0.3 Enterprise Edition.
I have a strange request here - do not know if this is possible without going to procedure...
...
Do not no stinkin' procedure:
WITH got_grp_id AS
(
SELECT the status, revision_id, revision_timestamp
ROW_NUMBER () OVER (ORDER BY revision_id)
-ROW_NUMBER () (PARTITION STATUS
ORDER BY revision_id
) AS grp_id
OF test_status
)
SELECT status
MAX (revision_id) AS revision_id
MAX (revision_timestamp) DUNGEON (DENSE_RANK LAST ORDER BY revision_id)
AS revision_timestamp
OF got_grp_id
GROUP BY status, grp_id
ORDER BY revision_id
;
For an explanation of the technique of Difference sets used here, see
-
Hello:
I'm fighting with digital table of 1 d writeing in a binary file and start a new line or insert a separator for each loop writing file. So for each loop, it runs, LABVIEW code will collect a table 1 d with 253 pieces of a spectrometer. When I write these tables in the binay file and the following stack just after the previous table (I used MATLAB read binary file). However whenever if there is missing data point, the entire table is shifted. So I would save that table 1-d to N - D array and N is how many times the loop executes.
I'm not very familiar with how write binary IO files works? Can anyone help figure this? I tried to use the file position, but this feature is only for writing string to Bodet. But I really want to write 1 d digital table in N - D array. How can I do that.
Thanks in advance
lawsberry_pi wrote:
So, how can I not do the addition of a length at the beginning of each entry? Is it possible to do?
On top of the binary file write is a Boolean entry called ' Prepend/chain on size table (T) '. It is default to TRUE. Set it to false.
Also, be aware that Matlab like Little Endian in LabVIEW by default Big Endian. If you probably set your "endianness" on writing binary file as well.
-
Ungroup a group and keep the scriptlabel for each item in the Group
Hello
does anyone know how to ungroup a group of rectangles with a certain tag (example groupA) give one every rectangle a clean label (the same text groupA)
I can find the Group and ungroup it but I can't label the rectangles...
var oPageItems = app.activeDocument.allPageItems;
for (var j = oPageItems.length - 1;) j > = 0; d-) {if (oPageItems [j] .label == ("groupA")) {oPageItems [j] .ungroup ()))}}
...???
Help, please
Hello
front
oPageItems [j] .ungroup ();
go through the loop and set a label for each item within the Group:
for (var k; k)< opageitems[j].length;="">
oPageItems [j] [k] .label = "groupA";
assuming that your oPageItems [j] is a group indeed.
I hope that...
-
Dear administrators,
I created the user but now I have a requirement for the granting of privileges to view all objects in the DB in the data base and discovers the DOF for each.
Any help please
Ritz
Thanks to advise all the
-
LabVIEW allows to read an Excel file to a control and add a checkbox for each line
As say the topic, I need to use labview to read an excel file and show it in a control, such as mclb; I should add a checkbox for each line then allow me to choose the line I want. What should I do? Thank you very much.
guiming wrote:
I can read an Excel file to a spreadsheet, but I have no idea how to do to add a checkbox for each line.
Sometimes, all you need to do is Google. https://decibel.NI.com/content/docs/doc-25000
-
Recovering the year max for combination when the parameters are not exists
I try to query a table that maintains cumulative information by calendar_year and calendar_period. The problem I encounter is that if I want to ask the total of the transaction for a combination of accounting from a certain calendar_period and calendar_year, I need get the max calendar_year and calendar_period for the previous year or period for the current_year and max calendar_year by combination of accounting (Fund, org prog (, acct) which falls outside the parameters in my where clause, which for this example would be calendar_year = '15' and calendar_period = '03'. For most of all sense I'll post and excerpt from my table.
create table
CREATE TABLE "MAXTABLE" ( "CALENDAR_YEAR" NUMBER, "CALENDAR_PERIOD" NUMBER, "AMOUNT" NUMBER, "FUND" VARCHAR2(20 BYTE), "ACCOUNT" VARCHAR2(20 BYTE), "ORG" VARCHAR2(20 BYTE), "PROG" VARCHAR2(20 BYTE) )
values in the table.
REM INSERTING into MAXTABLE SET DEFINE OFF; Insert into MAXTABLE (CALENDAR_YEAR,CALENDAR_PERIOD,AMOUNT,FUND,ACCOUNT,ORG,PROG) values (15,2,25,'202118','2071','3662','121'); Insert into MAXTABLE (CALENDAR_YEAR,CALENDAR_PERIOD,AMOUNT,FUND,ACCOUNT,ORG,PROG) values (15,3,150,'202118','2070','3662','121'); Insert into MAXTABLE (CALENDAR_YEAR,CALENDAR_PERIOD,AMOUNT,FUND,ACCOUNT,ORG,PROG) values (14,12,50,'202118','2040','3662','121'); Insert into MAXTABLE (CALENDAR_YEAR,CALENDAR_PERIOD,AMOUNT,FUND,ACCOUNT,ORG,PROG) values (14,3,100,'202118','2070','3662','121'); Insert into MAXTABLE (CALENDAR_YEAR,CALENDAR_PERIOD,AMOUNT,FUND,ACCOUNT,ORG,PROG) values (13,14,50,'202118','2010','3662','121');
so now I want to run a query which would show me the total amounts by combination of accounting (Fund, account, org, prog) and I'd like to get it from calendar_year '15' and calendar_period ' 03 ".
I need essentially back on the period and the year previous years courses and get the max (calendar_year) and the max (calendar_period) for the Fund, account, org, combination of prog that is not in the calendar_year '15' and calendar_period ' 03 "
so the results would look something like below. Also the max_period and max_year could be in the same calendar year that I ask for this combination of accounting, an example of this is the 2070 account in the result below.
I would like to run a query similar to this one
SELECT CALENDAR_YEAR, CALENDAR_PERIOD, AMOUNT, FUND, ACCOUNT, ORG, PROG FROM MAXTABLE WHERE CALENDAR_PERIOD = '03' AND CALENDAR_YEAR = '15';
but it would give me only the amounts on the table which exist for this year and the period. I also need to get the max calendar_year and max_calendar_period before calendar_period 03 and calendar_year 15 and add those to my request.
.expected output:
Calendar_Year calendar_period amount Fund account org PROG 15 2 25 202118 2071 3662 121 15 3 150 202118 2070 3662 121 14 12 50 202118 2040 3662 121 13 14 50 202118 2010 3662 121 noticed that I'm not getting the $100 for account 2070 calendar_year question 14 and calendar_period ' 03 ". This point has already had a calendar_year max 15 and period 2 so I exclude it, since is less than 15 calendar_year but it is also a lot already this combination of accounting.
Hope it makes sense.
Sorry, I did not single-digit into account correctly. Two years and by the need to be wrapped with to_char as:
TO_CHAR (yr, 'fm00') | TO_CHAR (per, 'fm00')<=>=>
John
-
count the number of targets, devices and paths by hba for each host with powercli 5.5
Hi all
I'm writing this Question again in the community, was not able to found the answer I was looking for in the nets:
https://communities.VMware.com/thread/516226?start=0 & tstart = 0
https://communities.VMware.com/thread/293531
I went through the scripts provided in the community, but seems that t not work on powercli 5.5.
///
# The target account, devices and paths for each host
Get-Cluster $cluster | Get-VMHost | Sort-Object-property name. {ForEach-Object
$VMHost = $_
$VMHost | Get-VMHostHba-type FibreChannel | Sort-Object-property device | {ForEach-Object
$VMHostHba = $_
$ScsiLun = $VMHostHba | Get-ScsiLun
If {($ScsiLun)
$ScsiLunPath = $ScsiLun | Get-ScsiLunPath | `
Where-Object {$_.} Name - like "$($VMHostHba.Device) *"} ".
$Targets = ($ScsiLunPath |) »
Group-object - property SanID | Measure - Object). County
$Devices = ($ScsiLun |) Measure - Object). County
$Paths = ($ScsiLunPath |) Measure - Object). County
}
Else {}
$Targets = 0
$Devices = 0
$Paths = 0
}
$Report = "" | Select-Object - property VMHost, HBA, target devices, paths
$Report.VMHost = $VMHost.Name
$Report.HBA = $VMHostHba.Device
$Report.Targets = $Targets
$Report.Devices = $Devices
$Report.Paths = $Paths
$Report
}
}
///
I went through the script LucD posted below: but it's not exactly what I'm looking for.
LucD : can you please change the same for me please. to count the number of paths per hba for each host with powercli 5.5, devices and targets.
//
$esx = get-VMHost < host name >
foreach ($hba to (VMHostHba Get - VMHost $esx - type "FibreChannel")) {}
$target = ((get - see $hba. VMhost). Config.StorageDevice.ScsiTopology.Adapter | where {$_.} Adapter - eq $hba. Key}). Goal
$luns = get-ScsiLun - Hba $hba - LunType 'disk '.
$nrPaths = ($target | % {$_.}) Lun.Count} | Measure - Object - sum). Sum
Write-Host $hba. Device ' target: ' $target. County "devices:" $luns. County ' path: ' $nrPaths
}
//
I'll be grateful for any help.
Tarun Gupta
Try something like this
{foreach ($esx in Get-VMHost)
foreach ($hba to (VMHostHba Get - VMHost $esx - type "FibreChannel")) {}
$target = ((get - see $hba. VMhost). Config.StorageDevice.ScsiTopology.Adapter | where {$_.} Adapter - eq $hba. Key}). Goal
$luns = get-ScsiLun - Hba $hba - LunType "disk" - ErrorAction SilentlyContinue
$nrPaths = ($target | % {$_.}) Lun.Count} | Measure - Object - sum). Sum
$props [ordered] = @ {}
VMHost = $esx.name
HBA = $hba. Name
Target = $target. County
Device = $luns. County
Path = $nrPaths
}
New-object PSObject-property $props
}
}
-
Select several Kings and set the properties for each of them
Hi all
I am currently working on a project on the thermal camera images. What I have to do is to define multiple regions of interest and assign specific properties such as temperature and emissivity of these Kings.
So I was wondering:
1 that is, possible to select several kings with a table keeping up-to-date of the Kings, the user has chosen on the front? (Or each KING might have a cluster on the front panel that contains its properties, which can be changed later.)
2. is that possible to set specific properties such as temperature in the specfic KING, these properties and will be updated for the return on investment?
Thank you so much and looking forward to some good ideas or tips.
See you soon,.
Version
Hi all
The attachment is what I've done now. However, instead create a .txt file to display information, it would be perfect to display the name of the KING and its properties in Control Panel before, as in the first column is 1 KING, KING 2, 3 return on investment, etc, and the other columns will be responsible for some information on the return on specific investment and its properties... Because I couldn't find something similar here, I really need your help.
Thank you
Version
-
Remove the secondary controller and tertiary high availability for each access point
I want to remove secondary and tertiary sector controller of high availability for each access point. I have more than 900 APs associated with a Version of the WLC 8510 8.0.121.0 software. What is the best/better way to remove secondary and tertiary controller?
Or I can create a model first. We use version 2.2Hello
Easiest way:
Yes you can do this by using the first Cisco Infrastructure, you can create a Setup AP Lightweight model to specify the name of the PDC and the IP address and specify an empty value (choose the first empty option in the drop-down list) and 0.0.0.0 for the secondary and tertiary sector controllers. Then you can apply this model to the AP, and she must remove (virgins all) values for these fields.
Long way:
Yes there is no clean way to remove it from the CLI. you need to manually remove each on the AP.
Concerning
Remember messages useful rates
-
change the shade and use those unique for each site
I'm not a big user of Illustrator so am not comfortable with the nuances yet. In Muse, I want to have a unique swatch panel for each Web site. How can I remove unused colors (I know how to add new ones) and then attach this unique sample for this unique site?
Right-click on any color
Click on 'delete unused nuances '.
You cannot delete black or white. If a color is which is in the background, as the error message red in a contact form, then it won't let you remove used red unless you change the color of the error message.
-
I have a T2 tungsten used for business (in sync with your desktop XP and laptop XP). I recently got a Palm V I intend to use for personal applications / hobby (a controller requiring a serial connection). 2 devices may not be synchronized - in fact, they need their files and separate applications. The current installed desktop application comes from the T2 Setup disk (V 4.1.4).
I need to load an older version of Palm Desktop for Palm V of load/install programs?
How can I load applications Palm v and keep the Palm V files to take charge of the T2 (and now the files synchronization T2 Palm v)?
DRM for all the advice!
Hello and welcome to the Community Forums of Palm.
As long as you keep a separate Hotsync ID for each of the two devices, you should be able to sync the V of the same installation of office. Create a separate Hotsync ID will also create a folder of device separated on the desk, at which all the separate data and third-party applications will be synchronized.
Palm knowledge base Article explains how Hotsync two devices on the same office, but also a device on two different workstations:
http://tinyurl.com/kq4c5Message relates to: None
-
View the number of paths and the political path for each data store
Hi all
Seem to be stuck on this one. and all that seems to be able to find through topis and scripts for the air path setting. All I have to do is list each data store to its policy of access road and the number of path for the data store on the host computer.
I'm gussiing it uses the get-vmhoststorage cmdlet?
Any help much appriciated.
Phil
Try something like this
Get-VMHost | %{ $esxImpl = $_ $_ | Get-ScsiLun | where {$_.LunType -eq "Disk"} | %{ $_ | Select @{N="HostName";E={$esxImpl.Name}}, @{N="Path";E={$_.CanonicalName}}, @{N="Policy";E={$_.MultiPathPolicy}}, @{N="Number";E={($_ | Get-ScsiLunPath).Count}} } }
____________
Blog: LucD notes
Twitter: lucd22
-
How to divide a circle and the fill color for each individual segment
I know that sounds easy, sorry I'm pretty new to illustrator.
I need to divide a circle into 7 sections and then fill each of them individually. I tried the polar grid tool to divide the circle, but I couldn't turn each segment into distinct sections that I could color individually.
The cirlce does not break upward into segments but creates a number of paths, the outline of the circle is a unique path.
Does anyone know a quick solution to this? Am approaching this the wrong way? Any help would be GREATLY appreciated.
Thanks for your time,
Tony
You can use the live paint after split.
are you lookin for?
-
Determine the maximum value and the minimum value for each value in the 2D array
Hello, I need help please. Sorry my English is not very good. I have table 2D in which each value describes a waveform, I needed a time interval to determine the minimum and maximum value of each element of the array.
Maybe you are looking for
-
Wanted: Cannot resize the window on any browser size
I can't resize one of my windows. Even if I go up the two small boxes in the right corner and get the arrows of the rocker, I can't always resize. Each tab takes up the entire screen. I need to have several windows open in different sizes, so this is
-
Can I connect to the internet via Windows ME?
I have a HP with a hard drive 10G under Windows Millennium Edition. The computer has a USB port, but no opening for a network card. The Control Panel on ME seems to have capacity only for the connection with a phone modem.
-
I have several networks that have shown up on my computer I have has not put there
I have several networks appear on my network card that I did not put there.
-
I get no sound on Windows Media Player.
I have the media player 11 and it has no noise and both pregnant and computer volumn is in place. It was before but now nothing? Original title: Media player 11 no sound and speakers are on why?
-
Hi, I want to barr of certain nr. I went into settings - call settings - call barring - call settings - all entrants, now she wants a password. I'm in the right place?