Group by GEOM and get unique points
Hello,
I need some help with a spatial query. I have a table of addresses and wanted to know if there is an easy way to group by x and y coordinates , so that I just get one record for multiple addresses with the same coords (and do simple clustering).
This is my current sql statement
select map_id, m.shape.sdo_point.x as X, m.shape.sdo_point.y
from MAPS m
where MDSYS.SDO_RELATE (m.SHAPE,
MDSYS.SDO_GEOMETRY(2003,
8311,
NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3),
MDSYS.SDO_ORDINATE_ARRAY(<%= mbrCoords[3]%>, <%= mbrCoords[2]%>, <%= mbrCoords[1]%>, <%= mbrCoords[0]%>)), 'mask=ANYINTERACT') = 'TRUE';
Hi,
another way would be like this (geom is SDO_GEOMETRY)
-- 2D
select A.* from
select t.id, gv.x,gv.y
from <TABLE> t, table(sdo_util.getvertices(t.geom)) gv
) A, (
select count (gv.x||gv.y) ct , gv.x,gv.y
from <TABLE>, table(sdo_util.getvertices(geom)) gv
group by gv.x,gv.y
) B
where A.X = B.X and A.Y = B.Y
and B.ct > 1
-- 3D
select A.* from
select t.id, gv.x,gv.y ,gv.z
from <TABLE> t, table(sdo_util.getvertices(t.geom)) gv
) A, (
select count (gv.x||gv.y||gv.z) ct , gv.x,gv.y,gv.z
from <TABLE>, table(sdo_util.getvertices(geom)) gv
group by gv.x,gv.y,gv.z
) B
where A.X = B.X and A.Y = B.Y and A.Z = B.Z
and B.ct > 1
Similar Messages
-
Just got an HP 8600 printer. When I get to point of "password to allow HP installer to make changes" it won't accept any of my passwords, and there is nothing that says "check here to get password" Help????
Karstenfromca wrote:
Just got an HP 8600 printer. When I get to point of "password to allow HP installer to make changes" it won't accept any of my passwords, and there is nothing that says "check here to get password" Help????
It's looking for the password for an Admin user on the machine (probably you) use the one you log onto the computer with -
Strings comparision and get unique string in pure sql,
Dear all,
Here is two strings
S1='A,B,C,D,F';
s2='C,F,H,B,A,K';
output should be like unique string values ..
S3= A,B,C,D,F,H,K;
How to get this in pure sql..
thanks in advance,
RootsHi,
In a relational database, each column of each row should store one value, not a repleating group of values, such as a delimited list. This is so basic to database design that it is called "First Normal Form". You don't have to follow rules like this, but, if you don't, your code will be complicated, inefficient, and error-prone. It sould be best to re-design your application so that each value was on a separate row.
If you can't do that, then you can start by splitting your delimitd lists into separate rows. Then you can easily fond the distinct values, and use any String Aggregation technique to combine the results into one output row.
Here's one way to do all that:
WITH got_params AS
SELECT 'A,B,C,D,F' AS str, 1 AS str_id FROM dual UNION ALL
SELECT 'C,F,H,B,A,K', 2 FROM dual
, got_part_cnt AS
SELECT str
, 1 + LENGTH (str)
- LENGTH (REPLACE (str, ',')) AS part_cnt
FROM got_params
, cntr AS
SELECT LEVEL AS n
FROM (
SELECT MAX (part_cnt) AS max_part_cnt
FROM got_part_cnt
CONNECT BY LEVEL <= max_part_cnt
, got_substr AS
SELECT DISTINCT
REGEXP_SUBSTR ( p.str
, '[^,]+'
, 1
, c.n
) AS sub_str
FROM got_part_cnt p
JOIN cntr c ON c.n <= p.part_cnt
, got_r_num AS
SELECT sub_str
, ROW_NUMBER () OVER (ORDER BY sub_str) AS r_num
, ROWNUM AS r
FROM got_substr
SELECT MIN ( SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
, 2
) AS unique_sub_strs
FROM got_r_num
WHERE CONNECT_BY_ISLEAF = 1
-- START WITH r_num = 1
CONNECT BY r_num = 1 + PRIOR r_num
;This works in Oracle 10.2.0.2.0 Express Edition, which is the only database I can use right now. For the main query, you should be able to say:
SELECT SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
, 2
) AS unique_sub_strs
FROM got_r_num
WHERE CONNECT_BY_ISLEAF = 1
START WITH r_num = 1
CONNECT BY r_num = 1 + PRIOR r_num
;but, when I try that on my database, I only get 'A,B' as the output. CONNECT BY is very buggy in Oracle 10.2; if you have Oracle 10.1, the simpler form might work.
The query above can be shortened some, but I wrote it this way to make it easier to understand.
You can, for example, combine the sub-queries got_sub_str and got_r_num. If you do, use DENSE_RANK instead of ROW_NUMBER.
This does not assume that the sub-qtrings are all 1-character long. If they are, then the query can be simplified.
For more about string aggregation, see
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php -
Using DateAdd and getting Null Pointer Error
I am using the following code below:
<cfoutput query="getpeople">
<cfset time2 = TimeFormat(getpeople.lunch_out_time,
"hh:mm")>
<!---<cfset time3 = DateAdd("h", 0, time2)> --->
<cfset time4 = DateAdd("n", 10, time2)>
I have commented out the adding 0 hours and am trying to add
10 minutes to time2 a variable that is set by getting a value from
a database however when I try and do this I get a
The system has attempted to use an undefined value, which
usually indicates a programming error, either in your code or some
system code.
Null Pointers are another name for undefined values.
Please help, thanks!No the issue was that I had someone in the dateabase with no
time listed so that was the issue. Took care of it and it's working
fine now :-) Thanks for the thought. -
Group by hour and get percentage of value on a particular
Hi All,
Oracle 11g
create table test_table_2 ( time_log TIMESTAMP(6), status number, names varchar2(500) );
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'7'hour ,1,'FN:Will,LN:Smith');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'7'hour ,0,'FN:Will,LN:Paul');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'7'hour ,0,'FN:Will,LN:Liza');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'7'hour ,0,'FN:Will,LN:June');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'6'hour ,0,'FN:Ann,LN:Smith');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'5'hour ,0,'FN:John,LN:Blair');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'4'hour ,1,'FN:Peter,LN:Lloyd');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'3'hour ,1,'FN:Sam,LN:Smith');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'2'hour ,0,'FN:Will,LN:Smith');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'1'hour ,0,'FN:Will,LN:Smith');
In the above record I want to see the percenatge of status coulmn being 1 for a given hour.
In other words in the above table
curtime - 7 should give 25%
curtime - 6 should give 0%
curtime - 5 should give 0%
curtime - 4 should give 100%
Currently I am doing two queries
1. grouping by hour for status being 1 and
2. grouping by hour for status being 0
and then calculating the percentage on java level.
I thought it will be lot simpler if it can be done in one shot in sql itself.
Appreciate your help with this.
_PeteWell, i wasn't sure what happened to curtime - 3, curtime -2 and curtime -1 ... but maybe this is a start for you.
create table test_table_2 ( time_log TIMESTAMP(6), status number, names varchar2(30) );
declare
l_timestamp timestamp := systimestamp;
begin
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'7'hour ,1,'FN:Will,LN:Smith');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'7'hour ,0,'FN:Will,LN:Paul');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'7'hour ,0,'FN:Will,LN:Liza');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'7'hour ,0,'FN:Will,LN:June');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'6'hour ,0,'FN:Ann,LN:Smith');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'5'hour ,0,'FN:John,LN:Blair');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'4'hour ,1,'FN:Peter,LN:Lloyd');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'3'hour ,1,'FN:Sam,LN:Smith');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'2'hour ,0,'FN:Will,LN:Smith');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'1'hour ,0,'FN:Will,LN:Smith');
end;
ME_XE?select
time_log,
count(case when status = 1 then 1 else null end) / count(*) * 100
from test_table_2
group by time_log
order by time_log asc;
TIME_LOG COUNT(CASEWHENSTATUS=1THEN1ELSENULLEND)/COUNT(*)*100
07-APR-10 08.46.22.557850 AM 25
07-APR-10 09.46.22.557850 AM 0
07-APR-10 10.46.22.557850 AM 0
07-APR-10 11.46.22.557850 AM 100
07-APR-10 12.46.22.557850 PM 100
07-APR-10 01.46.22.557850 PM 0
07-APR-10 02.46.22.557850 PM 0
7 rows selected.
Elapsed: 00:00:00.15 -
When I paste a group of cells and get a "bonk" sound when I select "paste."
Any ideas? The cells are not locked.
I discovered why it didn't want to paste... it was objecting to pasting a field with merged cells onto another field with merged cells. I thought they matched, maybe maybe not, I'm not sure. Anyway, I removed the columns alltogether and then pasted fresh. I hate to think what I would have had to go through if I would have lost other stuff that way, since un-merging all the destination cells would have been far far too much work. I guess that's what multiple tables on one worksheet are good for... though they have their drawbacks if you want compatibility with excel...
-
The address "<"Bay Times" [email protected]>" in the "To" field was not recognized. Please make sure that all addresses are properly formed
Don't know if this will work for AOL, but here's how I solved the problem last night: I stopped using the 2nd SMTP info, and only used the first one (alphabetically). It would appear to this layman that the iPhone doesn't like logging into an SMTP server with two sets of credentials. So, when you try to do it with the second account, it just chokes.
Here's step-by-step as to how I did it:
1 - Settings
2 - Mail, Contacts, Calendars
3 - Under Accounts, select the second account that uses the same SMTP server
4 - Outgoing Mail Server > SMTP
5 - Change Primary Server to Off (assuming this is the SMTP with this account's login credentials)
6 - Under Other SMTP Servers, change the duplicate SMTP server to ON
I had no problems after this and was immediately able to send an email from that account. -
When passing Node to parse() method get NULL pointer exception.
All,
I trying to pass a Node to parse method to get the NodeType object back and getting
null pointer exception.
Example
xml
<root>
<Test>
<someData>ABC</someData>
</Test>
</root>
if pass the Test node to get Test object back I am getting null pointer exception.
Thanks for all ur help
Shoebfile 2
~~~~
import javax.swing.*;
public class ExtendedPage extends BasePage
private JTextField objJTextField = null;
private JButton objJButtonBrowse = null;
Change the line in bold to
private JTextField objJTextField;
And everything works. -
my iphone 3 when turned on shows a picture of the jack and an arrow pointing to Itunes. I can't get it off this screen. help!
Do what you are being told. Plug the phone into a computer running iTunes and restore the phone.
-
Can anyone help me figure out how to sync my ipod with my purchased music? I have used several computer and at one point synced my ipod with a computer that only had about half of my music. My other computers are no longer working. Not sure how to get my purchased music back onto my ipod?
Hi kimcinma!
Your previous purchases are saved on iCloud even if you bought them on another computer. If you can't find them on your current computer, you might need to unhide them. Go to iTunes preferences, and click on Store Preferences. Then click the box for "show iTunes in the Cloud purchases". Then click on OK, and everything you've ever bought from iTunes on that Apple ID will show up in your library. You will need to download them from iCloud first before you can synch them to your iPod Classic. To do this, click on the little cloud with the arrow in it next to your song, and it will download to your computer. When you have the music that you want downloaded, plug in your iPod and synch away. Hope this helps!
Sandygirl -
I tried to upgrade to ios4 by plugging my Ipad into Itunes on my desktop. I got an error message as it was downloading. Now my Ipad won't turn on at all. All I get is a pic of the plug and an arrow pointing to the Itunes logo. I tried to reset, but nothing works. When I try to plug the Ipad into my desktop and access Itunes, my Ipad doesn't show up on the Itunes screen.
You need to restore your iPad using recovery mode and the process is covered in this article.
iPad: Unable to update or restore.
http://support.apple.com/kb/ht4097 -
When I havent got my ipad connected to a power supply I get an image on my ipad of the usb cable with an arrow pointing to a itunes icon and no matter what you try and do iyt stays on that for a few seconds and then switches off the ipad, connecting it through usb into itunes on my PC (XP) this image says on the screen but I get a message on itunes saying itunes has detected an ipad in recovery mode and mneeds to be restored - when I fire off the restore through itunes after a few minutes it comes back and says it cannot restore and give an error message 1603. I have also repeated the process through my wife's laptop (Vista) and get the same situation -it is an 32GB Ipad 3 purchased last November - any ideas ?
Try and turn off iPad/iPod and proceed to step 3 of Recovery Mode.
Recovery Mode
1. Disconnect the USB cable from the device, but leave the other end of the cable connected to your computer's USB port.
2. Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.
3.While pressing and holding the Home button, reconnect the USB cable to the device. The device should turn on.
4. Continue holding the Home button until you see the "Connect to iTunes" screen. When this screen appears, release the Home button. iTunes should alert you that it has detected a device in recovery mode. Click OK, and then click Restore to restore the device.
Note: Data will be lost. You may have to repeat the above many times. -
I just recently upgraded to the new itunes and getting this, ADAdPolicyEngine_DidEnterStation, could not be located in the dynamic link library C:|programsFiles(x86|itunes.dll, itunes.exe Entry point not found itunes Error 7 windows errors127
See iTunes launch errors caused by iAdCore.dll.
Review the rest of the user tip if required.
tt2 -
After I exported a PDF to a Word doc and downloaded it, I can't get the pointer tool to work. When I click on the document text, the only tool is the "move" tool. I can't edit or select text. Please advise.
Version of Adobe: Adobe ExportPDF (not Pro)
Operating system: Windows 8.1
Steps I am taking: When the PDF file is selected and opened, I clicked on Tools menu on right side of the screen; then I clicked on Select PDF file; then under Convert To, I selected Microsoft Word (*.docx); then I hit the box below that; and clicked Convert. I then see the message that says it is Converting to Export PDF Online. Then I see a link below that, that says Download Converted File. This takes me online to Adobe Acrobat .com, where, I see the command, Export PDF, and see a blue box on the same screen that says Select PDF Files to Export. I click on the thumbnail of the file I want to export. This brings up, online, a screen containing the file I wanted to convert to Word. Then, on the same screen, I click on the icon on the right hand of the screen that says Download. then I click on the box on the bottom the screen that contains the Word document I had wanted to convert. This brings up the Word doc. in Compatibility Mode the latest Word version, which I am unfamiliar with and which has a Picture Tools tab that I cannot escape from and I cannot get any selection tool other that the Move pointer, and I cannot find the Select text pointer to select any text on the page. I don't want this Word version and do not know how to return to the old version of Word that I am familiar with.
Can you help me, please?
Theresa Julia Schuer -
since updating itunes yesterday I now can't open it and get a pop up box about the procedure entry point not being located. anyone able to help?
these are the boxes that open up:
I am unsure as to wether I need to unistall and start again but then worry about the vast amount of songs already in the folder that I would have to reload.anyone able to help me with the above?
Maybe you are looking for
-
Error message while posting goods issue.
Hi, Please help me with the following problem.. I have created Sales Order, Delivery & also created the Transfer Order number. After creating Transfer ordering, while submitting post goods issue, when I click on PGI, I get "Posting only available for
-
HP Officejet All-in-one Automatic Document Feeder (ADF) Roller
I have a problem which I believe is mechanical. The roller on the ADF will not descend to the pressure plate when I try to copy or fax from the ADF. I talked to the online chat people and they kept trying to get me to remove the faceplate and clean
-
Dear All , i hv posted my problems before. My. Calendar does not work in Enter-Query Mode. It says 'Function Key Not Allowed' It's Because of the Code(Go_Block) in Get Date procedure in the date package. Any Suggestion on this will be highly apprecia
-
Exp/imp between 10g and 9i
Hi Gurus, In project we would like to transfer data from oracle 10g to 8i. Option selected in exp data from 10g and import to 9i. From 9i again export and import to 8i. Is there any issue between 10g and 9i and 9i to 8i ? Will normal exp file will wo
-
MySql + CMP + capture-schema + deploy tool
Hi everybody, I am trying to design a very simple CMP Entity Bean and packaging it with the deploy tool. I have produced a very simple schema of a single table and i am trying to map it on the bean, Using the deploy tool, I go on the CMP Database (SU