July 28, 2018 at 11:24 am
saravanatn - Saturday, July 28, 2018 11:13 AMtvrarundeepak - Saturday, July 28, 2018 10:52 AMsaravanatn - Saturday, July 28, 2018 10:37 AMtvrarundeepak - Saturday, July 28, 2018 10:32 AMtvrarundeepak - Saturday, July 28, 2018 10:31 AMsaravanatn - Saturday, July 28, 2018 10:24 AMtvrarundeepak - Saturday, July 28, 2018 10:18 AMHi Saravanan,
Output should like this
FirstName FamilyName
Arun DonOnly you want the below as output:
FirstName FamilyName
Arun DonAre you sure?
yes
like there is n number of familyname and firstname
your explanation is not clear. Can you kindly post expected output?
In the below table we have three family names for example
Output should be like this
Firstname should be randomly selected for each family.
Firstname Familyname city
Mathu Don US
Peri Chennai TN
no Do ys
Below query should work I thinkSELECT
MAX(Firstname) over(partition by FamilyName,City order by Firstname) as Firstname,
FamilyName,City
FROM dbo.people;
----------------------------------------
SELECT
MIN(Firstname) over(partition by FamilyName,City order by Firstname) as Firstname,
FamilyName,City
FROM dbo.people;
SELECT
MAX(Firstname), FamilyName, City
FROM dbo.people
GROUP BY FamilyName, City
Viewing post 16 (of 15 total)
You must be logged in to reply to this topic. Login to reply