SQL Server 2008: how to write query for multiple columns in select and in group by only 1 column -


my requirement how write query multiple columns in select , in group 1 column. in multiple columns of select, first column have used distinct. want group 1 column 3rd column. please tell me one.

i getting result this:

d2a08528-ffba-492d-af51-50d6cc10c5a4    b.vithoban@gmail.com    e0f127ed-da67-45f4-a2c5-c0e89cb5e1b4    5 6110e173-419b-4c1b-8524-6d9ef39d27e7    bonthapally123@gmail.com    e0f127ed-da67-45f4-a2c5-c0e89cb5e1b4    5 52d7da02-9415-447f-9df4-8d327e599347    rama6452@gmail.com  e0f127ed-da67-45f4-a2c5-c0e89cb5e1b4    5 9fcc3c51-3bb7-4a18-a1e5-9b4c6b657ab2    krishna.rama718@gmail.com   e0f127ed-da67-45f4-a2c5-c0e89cb5e1b4    5 eb79fc72-5144-445e-8ee7-d3a195902210    venkatanarasaiahmannam@gmail.com    e0f127ed-da67-45f4-a2c5-c0e89cb5e1b4    5 c04ea2ef-8311-4194-b67d-d88c1cda912d    ramakrishna2526@gmail.com   e0f127ed-da67-45f4-a2c5-c0e89cb5e1b4    5 40d24f2e-7d3a-48a8-adcf-208e2f463c81    sivaputta123@gmail.com  c83583d4-c08a-4aff-93fb-5fb91654d320    2 de42d201-7513-43bd-98a1-4f5b52c799a3    bonthapally123@gmail.com    7c6fa760-0b13-4629-9383-c7d943a1de8c    1 

but need result this:

d2a08528-ffba-492d-af51-50d6cc10c5a4 b.vithoban@gmail.com e0f127ed-da67-45f4-a2c5c0e89cb5e1b4   5  40d24f2e-7d3a-48a8-adcf-208e2f463c81 sivaputta123@gmail.com  c83583d4-c08a-4aff-93fb-5fb91654d320    2  de42d201-7513-43bd-98a1-4f5b52c799a3  bonthapally123@gmail.com 7c6fa760-0b13-4629-9383-c7d943a1de8c   1 

please try:

select * from(     select          row_number() on (partition 3rdcolumn order 3rdcolumn) rnum,         *      yourtable )x rnum=1 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -