In SQL Server 2008 R2 I have created some polygons. I have also selected which polygon is overlapping another one Now I want to know overlapped area or percentage.
For area I am trying following SQL
SELECT location.STArea()
FROM
( SELECT location.STIntersection(
(SELECT LOCATION
FROM TEST.dbo.cn_overlap_trn
WHERE plot_no = '657065700016801' ) )
FROM TEST.dbo.cn_overlap_trn
WHERE plot_no ='657065700016701') ;
in above SQL
SELECT location.STIntersection(
(SELECT LOCATION
FROM TEST.dbo.cn_overlap_trn
WHERE plot_no = '657065700016801' ) )
FROM TEST.dbo.cn_overlap_trn
WHERE plot_no ='657065700016701';
is running fine but when I add STArea()
function it results an error
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near ';'.
You need an Alias for your subquery say A
and also to your functions specially in your inner query for example:
Select location.STArea() as Area from
(
select
location.STIntersection(
(
select location from TEST.dbo.cn_overlap_trn where plot_no = '657065700016801'
)
) as Intersection
from TEST.dbo.cn_overlap_trn
where plot_no ='657065700016701'
) A ;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.