Jump to content

Recommended Posts

Posted

I don't know what are the needs but modify the query like this..

 

;WITH cte AS (
 select -1 AS a, u.ID AS [uid], -1 AS b, g.ID AS [gid], g.Name, RANK() OVER
    (PARTITION BY u.ID ORDER BY u.ID) AS [Rank]
 
from vwUsers u 
join vwGroups g on g.Name = 'abc' 
join vwOrders o on o.ShipToID = u.LinkID and o.ProductID = 123
 
) SELECT a, [uid], b, [gid] FROM CTE WHERE RANK = 1
Posted

 

I don't know what are the needs but modify the query like this..

;WITH cte AS (
 select -1 AS a, u.ID AS [uid], -1 AS b, g.ID AS [gid], g.Name, RANK() OVER
    (PARTITION BY u.ID ORDER BY u.ID) AS [Rank]
 
from vwUsers u 
join vwGroups g on g.Name = 'abc' 
join vwOrders o on o.ShipToID = u.LinkID and o.ProductID = 123
 
) SELECT a, [uid], b, [gid] FROM CTE WHERE RANK = 1

 

 

This helped thank you all.. 

Posted

 

group by use cheyacha? 

 

 

 

Happy ga use cheyyi.. adi kooda distinct istadi.

×
×
  • Create New...