sql server - Identifying the unique values that form part of a SQL sum query -


I have 2 questions that I would like to work together:

1) A question of geometry The number is within a certain distance of another and the result is only where the count is more than 6 digits;

2) A query returns unique IDs for all points within that distance (without any counting and without at least records)

I generate a single query All (and only) records are expressed in the first query, which will be t2 from the new_ref table. (Ideally the output will be in the form of columns in one line, but at the moment I can get the records listed against several rows in the same column, so this is my first objective and I leave the pivot bit later).

Obviously, the system is identifying the record to count them, so I think it is possible to ask which records are they? |

The second question rejects the result. Should I structure it as a sub-query and if so, how do I do it?

The question is 1:

  DECLARE @radius float = 50 SELECT t1.new_ref, t1.hatrisref, SUM (case when t1.geolocation.STDistance (t2.Geolocation) And lt; = @ radius then 1 other zeros) Group size 'Table 1 to T1, Table 1 T2, WHERE [t1]. [[new2ref]! = [T2]. [New_f] Group by [T1]. [New_fiber], [t1]. [Hatric] HOWING SUM (In case T1. Zolocation. STDSTANCE (T2 geolocation) and LT; = @ RDS 1 rest 0) Order order by [T1]. [New_f], [T1]. [Hatric]   

query is 2:

  select float = 50 as radius @ radius, t1.hatrisref, t1.new_ref, t2. From new_ref to Table 1 T1, WHERE [t1] as Table 1 T2. [New_ref]! = [T2]. [New_ref] and t1.geolocation.STDistance (t2.Geolocation) & lt; = @radius GROUP BY [t1]. [New_ref], [T1]. [Hetricef], T2. EnVE_f ORDER by [T1]. [Haatrisf], [T1]. [New_f], T2  
    

Yes, a sub The query will work:

  SELECT ... from table 1 to T1, T2 as WHERE t1.new_ref! = T2.new_ref and t1.geolocation.STDistance (t2.Geolocation) & lt; = @radius and 5 & lt; (Select number (*) Table 1 to T3 WHERE t1.new_ref! = T3.new_ref and t1.geolocation.STDistance (t3.Geolocation) & lt; = @radius)   



Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -