Adding count(*) to SQL Server query -


I am trying to find a way to add a query to the output of my query:

 Select from * Code (select ID) as the name of 'Event Site', as the PlaceName piece, coordinates in the form of venueLatLng, (3959 * acos (cos (radians ('xx.xxxxxx')) * Cos (radial (SUBSTRING (venueLatLng, 1, CHARINDEX (',', venueLatLng) -1)) * cos (radians (SUBSTRING (venueLatLng, CHARINDEX (',', venueLatLng) + 1, 1000)) - radians '- xx.xxxxxxx')) + sin (radians ('xx.xxxxxx')) * sin (radians (SUBSTRING (venueLatLng, 1, CHARINDEX ( ',', VenueLatLng) -1))))) Distance from the marker) Where the distance of TMP is & lt; 30 order according to the distance;  

The way I tried to do this:

  SELECT * FROM (SELECT id, 'Event Location' AS name, placeName as snippet, PlaceLatLng AS coordinates, COUNT (*) rCount, (3959 * acos (cos (radians ('xx.xxxxxx')) * cos (radians (SUBSTRING (venueLatLng, 1, CHARINDEX (',', venueLatLng) -1)) As (* (SUBSTRING (venueLatLng, CHARINDEX (',', venueLatLng) + 1, 1000)) - radians ('- xx.xxxxxxx')) + sin (radians ('xx.xxxxxx')) * Sin (radians (SUBSTRING (space station, 1, fourteenx (',', location tag) -1)))) Distance from marker) TMP where distance and lieutenant; 30 order according to the distance;  

This error is:

The column 'Marker.Id' is invalid in the selection list because it is not included in any one function or by group Section

How can I do this correctly? Use analytical version of

COUNT , and assign it to your Make sure to enter the external query so that it is where the distance .

  SELECT TMP. *, COUNT (*) over () AS RCount FROM (SELECT id, 'Event location' AS name, placeName AS snippet, venueLatLng AS coordinates, (3959 * acos (cos (radians ('xx.xxxxxx')) * cos ( Radians (SUBSTRING (venueLatLng, 1, CHARINDEX (',', venueLatLng) -1)) * cos (radians (SUBSTRING (venueLatLng, CHARINDEX (',', macro lat long) + 1, 1000) - radians (' - sin (radian ('xx.xxxxxx')) * sin (radian (substrate (place label, 1, fourteenx (',', location tag) -1)))) distance from marker) TMP where distance and lieutenant; 30 order according to the distance;  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -