I have two tables Users and UserAttributes in SQL DB.
Table have structure like
Out required is
My attempted query
Select * from (
Select u.UserId,u.Username,u.UserEmail,ua.objectName,ua.objectValue
from Users u join userAttribute on u.UserId=ua.UserId
where ua.objectName='city' or pv.objectName='phone')) results
PIVOT (count(UserId)
For objectName IN ([city],[phone])) As pivot_table;
Current output
Still it is an double entry also for the reason I am not aware the city and phone results are in 0 and 1 (boolean).
Please help getting the desired output.