Tuesday, 15 July 2014

syntax - How to use DISTINCT in nested personal geodatabse SQL in ArcGIS -



syntax - How to use DISTINCT in nested personal geodatabse SQL in ArcGIS -

i have statement used in arcgis personal geodatabse. selects top 3 records in [mycolumn1], not if [mycolumn2] equals inline variable.

[mycolumn1] in(select top 3 ( [mycolumn1] ) mytable [mycolumn2] <> %variable% order [mycolumn1] desc)

but need add together distinct function because times there repeated values in [mycolumn1] 4 records selected.

how include distinct in look arccrash , personal geodatabase can handle it? there lot on subject, nil specific working arc or @ to the lowest degree access.

this doesn't work

[mycolumn1] in(select top 3 ( [mycolumn1] ) mytable [mycolumn2] <> %variable% order [mycolumn1] desc distinct [mycolumn1] )

nor this

[mycolumn1] in(select top 3 ( [mycolumn1] ) mytable [mycolumn2] <> %variable% order [mycolumn1] desc grouping [mycolumn1])

well since isn't total query select top 3 going homecoming 3 records, if mycolumn1 has duplicates , select distinct returns 1 of has duplicate both of included in in statement. example.

firstname | lastname bob doe billy smith marie evans bob lock

if select * table firstname in (select distinct top 3 firstname table)

you 4 records because inner query homecoming ("bob", "billy", "marie") , since initial query (select * table firstname in ("bob", "billy", "marie")) wants records have 3 first names, have @ to the lowest degree 1 of names. solution here query.

select distinct firstname table firstname in (select distinct top 3 firstname table)

the problem when distinct need include column names in cannot lastly name column query.

sql syntax distinct arcgis

No comments:

Post a Comment