Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect without Group By Sql
    text
    copied!<p>I got some problems with this query i need all my selectors but i only want to group <code>aspnet_Users.Userid</code> how should i do this?</p> <p>Here is my query:</p> <pre><code>SELECT aspnet_Users.UserId, aspnet_Users.UserName, Friends.Verified, Friends.FriendUserId FROM [aspnet_Users] INNER JOIN Friends ON Friends.UserId = aspnet_Users.UserId OR Friends.FriendUserId = aspnet_Users.UserId WHERE aspnet_Users.UserId IN (SELECT UserId as Id FROM Friends WHERE FriendUserId='3d1224ac-f2ad-45d4-aa84-a98e748e3e57' UNION SELECT FriendUserId as Id FROM Friends WHERE UserId='3d1224ac-f2ad-45d4-aa84-a98e748e3e57') GROUP BY aspnet_Users.UserId, aspnet_Users.UserName, Friends.Verified, Friends.FriendUserId </code></pre> <p><strong>Stored Procedure structure:</strong></p> <p><strong>Tables</strong> [aspnet_Users] and [Friends]</p> <p><strong>Columns</strong> [aspnet_Users.UserId], [aspnet_Users.UserName], [Friends.Verified], [Friends.FriendUserId]</p> <p>That is the data that i need to get using the procedure, but the problem is that each user can have multiply friends which means if so there will be multiply Friends values. This is the reason why i can't group using those values cause it gives me dublicates with the wrong value. </p> <p><strong>Expected Output:</strong></p> <p><strong>aspnet_Users.UserId</strong> (This is the user id of the friend, note that it doesn't mean that its the FriendUserId)</p> <p><strong>aspnet_Users.UserName</strong> (This is the UserName of the friend based on the UserId explained above)</p> <p><strong>Friends.Verified</strong> (True or False. The Verified value in the Friends table on the friendship)</p> <p><strong>Friends.FriendUserId</strong> (The FriendUserId value from the table Friends)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload