none
Ms Access Last function equivalent function in T-SQL

    Question

  • Hi,

    I am new to SQL Server. I have table with information below. Some provider is listed twice in the table

    Provider Code Outlet Code Provider Province Phone First Visit Date Last Visit Date Supervision Score (%) Score of Critical Steps IUD Percentage of Critical Steps 80% Country Quality Service Critical Step Meet Quality Guideline
    5188 01-00-0068 HENG Vuoch Eng Banteay Meanchey (012) 958-919 4/2/2014 4/2/2014 91.66 2.43 81.37 No No No
    5188 01-00-0068 HENG Vuoch Eng Banteay Meanchey (012) 958-919 28-05-2014 28-05-2014 87.96 2.43 81.37 Yes Yes Yes
    5410 01-00-0110 Chhuoy Pannada Banteay Meanchey (016) 865-985 18-03-2014 18-03-2014 85.18 2.52 84.31 Yes Yes Yes
    5190 01-00-0123 Nhek Puthary Banteay Meanchey (012) 217-175 8/1/2014 8/1/2014 84.25 2.29 76.47 No Yes No
    5190 01-00-0123 Nhek Puthary Banteay Meanchey (012) 217-175 22-05-2014 22-05-2014 83.33 2.29 76.47 No Yes No
    5413 01-00-0184 Kou Mom Banteay Meanchey (097) 787-8280 11/2/2014 11/2/2014 89.81 2.64 90.19 n/a Yes n/a
    5413 01-00-0184 Kou Mom Banteay Meanchey (097) 787-8280 27-02-2014 27-02-2014 98 2.64 90.19 Yes Yes Yes
    5634 01-00-0264 Yoeub Chakriya Banteay Meanchey (012) 938-538 22-05-2014 22-05-2014 88.88 2.64 88 Yes No No
    5542 01-00-0601 Ngann Ratha Banteay Meanchey (012) 201-406 20-05-2014 20-05-2014 87.81 2.23 74.33 No Yes No
    5532 01-00-0913 Em Mouth Banteay Meanchey (012) 447-674 6/3/2014 6/3/2014 92.59 2.79 93.13 Yes Yes Yes
    5532 01-00-0913 Em Mouth Banteay Meanchey (012) 447-674 6/6/2014 6/6/2014 92.59 2.79 93.13 Yes Yes Yes
    5554 01-00-0920 Boa Tay Banteay Meanchey (012) 985-539 18-03-2014 18-03-2014 84.4 2.26 75.49 No Yes No
    5554 01-00-0920 Boa Tay Banteay Meanchey (012) 985-539 17-06-2014 17-06-2014 85.18 2.26 75.49 No Yes No
    5535 01-00-0922 Say Sav Dy Banteay Meanchey (012) 764-632 4/3/2014 4/3/2014 79.62 2.47 86.28 No Yes No
    5535 01-00-0922 Say Sav Dy Banteay Meanchey (012) 764-632 19-06-2014 19-06-2014 79.62 2.47 86.28 Yes No No
    5414 01-00-0963 Thorn Sao Rouey Banteay Meanchey (012) 673-017 9/4/2014 9/4/2014 82.4 2.58 86 Yes Yes Yes

    In Ms Access, I can reproduce list of unique provider using the last function (see table below) 

    How can I do it in SQL Server?

    Provider Code Outlet Code Provider Province Phone FirstOfFirst Visit Date LastOfLast Visit Date LastOfSupervision Score (%) LastOfScore of Critical Steps LastOfIUD Percentage of Critical Steps LastOf80% Country Quality Service LastOfCritical Step LastOfMeet Quality Guideline
    5137 06-00-0417 Kang Sophalna Kampong Thom (092) 954-367 22-04-2014 22-04-2014 87.03 3 100 Yes Yes Yes
    5138 06-00-0415 Nou Vichetra Kampong Thom (012) 773-102 20-03-2014 12/6/2014 96.29 3 100 Yes Yes Yes
    5140 06-00-0254 Yim Cheng Sim Kampong Thom (012) 725-597 4/3/2014 6/6/2014 96.29 3 100 Yes Yes Yes
    5143 06-00-0868 Long Chanthida Kampong Thom (012) 682-009 20-05-2014 20-05-2014 93.51 3 100 Yes Yes Yes
    5145 06-00-0969 Kong Sithan Kampong Thom (092) 914-384 1/2/2014 1/2/2014 95.36 n/a No n/a
    5146 06-00-0893 Kam Keng Kampong Thom (089) 664-617 11/3/2014 12/6/2014 87.03 3 100 Yes Yes Yes
    5148 06-00-1035 Heng Sonath Kampong Thom (012) 524-063 6/3/2014 3/6/2014 92.59 3 100 Yes Yes Yes
    5149 06-00-0845 Ieng Keatheng Kampong Thom (011) 667-795 18-03-2014 10/6/2014 87.96 3 100 Yes Yes Yes
    5157 07-00-0143 Ung Chetha Kampot (012) 976-371 12/4/2014 12/4/2014 90.74 2.76 92.15 Yes Yes Yes
    5188 01-00-0068 HENG Vuoch Eng Banteay Meanchey (012) 958-919 4/2/2014 28-05-2014 87.96 2.43 81.37 Yes Yes Yes
    5190 01-00-0123 Nhek Puthary Banteay Meanchey (012) 217-175 8/1/2014 22-05-2014 83.33 2.29 76.47 No Yes No

    Wednesday, July 09, 2014 6:18 AM

Answers

All replies