Jump to content

Recommended Posts

Posted

Hi, 

 

 naku unique values kavali from a row other than distinct method  can we use any other method ? 

 

select -1, u.ID, -1, g.ID, g.Name

from vwUsers u 

join vwGroups g on g.Name = 'abc' 

join vwOrders o on o.ShipToID = u.LinkID and o.ProductID = 123

 

u.ID duplicate values vasthunayi

Posted

whats this -1?

 

r u talking abt MS SQL SERVER?

yes ms sql server 

 

-1 just to differentiate columns 

Posted

naku aa q and nee A rendu ardam kale.. PK.gif

aa Element Attributes e Confusinga Unnayi....:P

 

Just Em cheyyalo (Main Prob.) Clarity ga chepthe..dhaaniki Solution Iccheste better...PK.gif

Posted

 

group by use cheyacha? 

 

yes group by cheyi...

u will get the distinct

Posted

WITH cte AS (

 

 

select -1, u.ID, -1, g.ID, g.Name, RANK() OVER
    (PARTITION BYu.ID ORDER BYu.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 * FROM CTE WHERE RANK = 1

Posted

WITH cte AS (


select -1, u.ID, -1, g.ID, g.Name, RANK() OVER
(PARTITION BYu.ID ORDER BYu.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 * FROM CTE WHERE RANK = 1


Agree
Posted

WITH cte AS (

 

 

select -1, u.ID, -1, g.ID, g.Name, RANK() OVER
    (PARTITION BYu.ID ORDER BYu.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 * FROM CTE WHERE RANK = 1

 

the column id was specified multiple times for cte  ani vasthundi 

×
×
  • Create New...