-4

I am having a u-sql query which fetch some from 3 tables and this query already had the GROUP BY. I want to fetch only top 10 rows, so i have to use the FETCH.

@data= SELECT C.id,C.Name,C.Address,ph.phoneLabel,ph.phone
FROM person AS C 
INNER JOIN
phone AS ph 
ON ph.id == C.id
     GROUP BY id
     ORDER BY id ASC
FETCH 100 ROWS;

Please provide me some samples. Thanks in Advance!

Arron
  • 1,134
  • 2
  • 13
  • 32

2 Answers2

0

I am not an expert or anything but few days ago I executed a query which uses both group by and order by clause. Here's how it looks: SELECT distinct savedposters.*, comments.rating, comments.posterid FROM savedposters INNER JOIN comments ON savedposters.id=comments.posterid WHERE savedposters.display=1 GROUP BY comments.posterid HAVING avg(comments.rating)>=4 and count(comments.rating)>=2 ORDER BY avg(comments.rating) DESC

HSD
  • 1
0

What is your exact goal? There is no relationship between ORDER BY and GROUP BY. In your query you have GROUP BY but there is no aggregation so the GROUP BY is not needed, plus the query would fail. If you're looking to limit the output by 10 rows then see the first example at Output Statement (U-SQL).