sqlhelp Posted September 25, 2014 Report Posted September 25, 2014 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
dotnetrockz Posted September 25, 2014 Report Posted September 25, 2014 whats this -1? r u talking abt MS SQL SERVER?
sqlhelp Posted September 25, 2014 Author Report Posted September 25, 2014 whats this -1? r u talking abt MS SQL SERVER? yes ms sql server -1 just to differentiate columns
macha Posted September 25, 2014 Report Posted September 25, 2014 you need to build something like this select -1, u.ID, -1, g.ID, g.Name from vwUsers u where exists(select * from vwGroups g on g.Name = 'abc') here are some examples http://www.techonthenet.com/sql/exists.php
JollyBoy Posted September 25, 2014 Report Posted September 25, 2014 you need to build something like this select -1, u.ID, -1, g.ID, g.Name from vwUsers u where exists(select * from vwGroups g on g.Name = 'abc') here are some examples http://www.techonthenet.com/sql/exists.php naku aa q and nee A rendu ardam kale..
sqlhelp Posted September 25, 2014 Author Report Posted September 25, 2014 you need to build something like this select -1, u.ID, -1, g.ID, g.Name from vwUsers u where exists(select * from vwGroups g on g.Name = 'abc') here are some examples http://www.techonthenet.com/sql/exists.php adi enti join ela cheshtam apudu ?
Hyderabad_Nawab Posted September 25, 2014 Report Posted September 25, 2014 naku aa q and nee A rendu ardam kale.. aa Element Attributes e Confusinga Unnayi....:P Just Em cheyyalo (Main Prob.) Clarity ga chepthe..dhaaniki Solution Iccheste better...
JollyBoy Posted September 25, 2014 Report Posted September 25, 2014 bhayyo.. naku clarity missing.. ardamayela chepte try chesta
vikuba Posted September 25, 2014 Report Posted September 25, 2014 group by use cheyacha? yes group by cheyi... u will get the distinct
JollyBoy Posted September 25, 2014 Report Posted September 25, 2014 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
Pandu_age40 Posted September 25, 2014 Report Posted September 25, 2014 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
sqlhelp Posted September 25, 2014 Author Report Posted September 25, 2014 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
Recommended Posts