Ms Access Last function equivalent function in T-SQL

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

What SQL Server version you are using? Since SS2012 we have LAST_VALUE function
http://msdn.microsoft.com/en-us/library/hh231517.aspx
SELECT * FROM
SELECT <columns>,ROW_NUMBER() OVER (PARTITION BY providercode ORDER BY date DESC) rn
) AS Der WHERE rn=1
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • Java Equivalent Function to Obfuscation DES3 Procedures

    I've read all of the notes and reports that I could find on both OTN and MetaLink, but I can't find a solution anywhere. Just hints, particularly in Note 232000.1 and Note 225214.1. I've been trying all of the variations that I can think of in test code with no success. I've also searched the net extensively.
    What I need is a code sample IN JAVA that provides equivalent functionality to the des3encrypt and des3decrypt procedures using raw values in the obfuscation toolkit.
    We have a number of huge databases in which we would like to use the obfuscation toolkit with DES3 3-key (192-bit) keys to manage encrypting
    confidential data. We need to be able to read this data from Java applications. Those applications must be able to decrypt the values encrypted using the toolkit. We must also be able to do the reverse, encrypt data in Java, store the encrypted values, the decrypt and access the data in PL/SQL using the toolkit.
    I've searched high and low, but I cannot find sample code anywhere for performing this functionality in an equivalent fashion.
    Thanks!
    Mark Scarton
    [email protected]

    Hi Mark,
    I encountered a similar challenge, were you able to figure out the solution for this problem?
    Thanks,
    Srikanth

  • Access Sequnce in Partner Function

    Hi
    We are using same transaction types for 3 different types of service orders functionality.
    Service order, Copy Service Order, Follow up service Order, we are defined partner function with below category, Client, Alternative Requester, Employee Responsible, Service Group..
    Scenario 1. 
    The Original service order has both Client & Alternative partner function fields with the same person i.e. u201CClient is equal to Alternative Requester, we require scenario as below
    i)      Copy service order partner functions are the same partner functions as the preceding (original) service order.
    ii)      FUSO alternative requester partner function will be copied from Original service order Client Partner Function partner function.
    Scenario 2:
    The Original service order has both Client & Alternative Requester partner function fields with different values i.e. u201CClient is not equal to Alternative Requesteru201D. Here it will impact on FUSO as described below
    i)         There is no effect to copy functionality i.e. Copy service order partner
               Function has same partner functions as the preceding (original) service order
    ii)     Effect on FUSO logic: Alternative requester partner function will be copied from original service order to FUSO alternative requester field.
    But as per scenario Client from Original service order should become Alternative Requester for FUSO,, Suggest perfect access sequence to satisfy above condition
    Regards
    Raju

    Hi,
    Create an access sequence with one step:
    1) Client from Preceding document
    in which the source should be preceding document and the details on the origin should be your client partner function.
    Then assign this access sequence to your Alternative Requester partner function.
    This should work.
    Regards.

  • @RELATIVE() equivalent function in Financial Reporting Studio?

    All,
    Is there an FR equivalent function to the @RELATIVE() function in Essbase?
    Specifically, I'm trying to select Level 0 descendants of a particular member.
    e.g. @RELATIVE(MEMBER,0) would be the equivalent function in Essbase.
    I've tried to use the RelativeMember function, but that does not appear to do the same thing.
    I also tried to union two selections, but that just returns an MDX error.
    e.g. assume I want to return child 2 and 3
    Dimension
    Parent A
    Child 1
    Parent B
    Child 2
    Child 3
    Lev0,Dimension NOT Descendant Parent A (this is not the actual syntax, but an explanation of what I tried). This returns an MDX error to do with "NOT".
    Any help is appreciated...

    That was extremely helpful. I was able to get it working with the following syntax
    Descendants of <Member> AND System-defined member list Lev0,<Dimension>
    Thanks again for your help.

  • What is the equivalent function of NIDAQYield in NI-DAQmx?

    I have to migrate from traditional NI-DAQ to NI-DAQmx for Window 7 64bits system.  I like to find the equivalent function of NIDAQYield in NI-DAQmx?

    As far as I can see here, NIDAQYield is simply a way to process system events, so I suppose calling ProcessSystemEvents () will be equivalent to calling it.I do not know of a native DAQmx function that does the same. It is to be said, though, that DAQmx way of handling acquisition process is different from Traditional DAQ one and direct translation is not always possible, so depending on how you migrate your code, calling those functions may be unnecessary.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Need a function equivalent to PERCENTILE_CONT for Oracle 8i

    I have been using PERCENTILE_CONT in Oracle 9i to find median and quantiles. Now, I need to run similar queries on a different database that is only Oracle 8i. Is there an equivalent function that I can use to give Quantiles?

    I've read the description of percentile_cont several times now, and I still don't understand it (never was good at statistics anyway, still don't understand why a flush beats a straight). there was no function in 8i, but is it possible to do it by combining other functions? not understanding what it does, I don't know.
    otherwise, all the analytics I've used can be solved by joining or outer-joining a table to itself - that's how we used to do them. for example, for SUM() OVER you join the table to itself, using = on all the selected columns expect the column you want to sum, that column becomes a <=. then group by all the columns in one isntance of the table, and sum the column from the other instance of it.
    some things might need to join the table 3 times, or use outer-joins. doing that give you the ability to know, on any given row, the total number of rows, it's RANK or ROW_NUMBER, etc.
    hope this helps. if you understand how percentile_cont works, you could probably construct a query yourself

  • Last execution time() function in webi

    Hi Everybody,
    If you use Last Execution time() function in webi it will give us something like: 9:36:53PM. But i need to minus 1hr from this.i should get the time as 8:36:53PM. Everytime i use this function i should minus one hour from the Last Execution Time().
    Thanks in Advance.

    The following formula will return a last execution time minus an hour.
    =If(FormatDate(LastExecutionDate(); "hh")="00"; "23"; FormatNumber(ToNumber(FormatDate(LastExecutionDate(); "hh"))-1;"00"))+FormatDate(LastExecutionDate(); ":mm:ss")
    There may be a better way of doing it but I have not found it.
    Regards
    Alan

  • Equivalent function for box3d which available in Postgis

    I have a road_network data I am trying to
    obtain all the values within a bounding box formed by lat long values,
    i tried below example but it compiled and produces some error 
    declare @exmp varchar;
    set @exmp = 'POLYGON(81.959545899804 25.243612186501,81.985879306176 25.2726072490010)'
    DECLARE @box geography = geography::STLineFromText(@exmp, 4326)
    SELECT source,target,geog4326.STAsText()
    FROM road_network
    WHERE geog4326.STIntersects(@box) = 1;
    in PostGIS theres a box3d, i like to know is there any equivalent function available in MS SQL Server ?

    a few problems here:
    1.
    run this- what do you see?
    declare @exmp varchar;
    set @exmp
    = 'POLYGON(81.959545899804 25.243612186501,81.985879306176 25.2726072490010)'
    print @exmp
    a varchar initialised without a size defaults to varchar(1)
    so set varchar to the required value or set it to varchar(max)
    2. A polygon requires at least 3 distinct points and the start and end points need to be the same. I'm assuming you just want to draw a line between the 1st & 3rd points of your bounding box and have the db engine draw the box around them. So you should
    be declaring it as a LINESTRING, not a polygon. Unfortunately geography doesn't have a .STEnvelope() function, so you'll need to convert the line to geometry, get the envelope, then convert back
    declare @exmp varchar(max);
    set @exmp = 'LINESTRING(81.959545899804 25.243612186501, 81.985879306176 25.2726072490010)'
    DECLARE @box geography = geography::STLineFromText(@exmp, 4326)
    -- Work out bounding box by converting to geometry via WKB, then using STEnvelope()
    DECLARE @boundingbox geometry = geometry::STGeomFromWKB(@box.STAsBinary(), @box.STSrid).STEnvelope();
    -- Convert result back to geography via WKB
    SET @box = geography::STGeomFromWKB(@boundingbox.STAsBinary(), @boundingbox.STSrid);
    (from
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/453d2fe8-bbe6-4047-90ce-556015c17e64/how-to-get-the-bounding-rectangle-of-a-geography)
    now you can intersect your @box.
    If this were geometry you could've just used .STFilter() on your linestring directly.. I'm not sure how .Filter() works with geography but investigate it as it'll be faster if your road_network table has correct spatial indexes.
    Jakub @ Adelaide, Australia

  • HTTP 404 Not Found while accessing Human Resource Intelligence functions

    Hi,
    Can anyone help me in resolving
    HTTP 404 Not Found while accessing Human Resource Intelligence functions
    error
    Instance : R12
    Thanks

    Hi,
    Apache log file is not showing any errors.What log files have you checked? Please check error_log and access_log files, you should find more details about the error in these logs.
    Thanks,
    Hussein

  • "Extract" filter or equivalent function

    Where do I find the "Extract" filter or equivalent function found on earlier versions of Photoshop?

    Norm, you'll have noticed the video is one of those super easy images they used to demo Refine Edge when it was first available?  I struggled with the tool for ages back then, finding a far from intuitive tool to use in real world situations, which is why I often use the Martin Evening tutorial on this forum, because he demos a difficult image, plus he shows how best you use it in the target image.  But I decided to make it look easy in my post above

  • Slow access to address book functions due to shared address books

    We have recently migrated from GW v8.0.3 on NetWare 6.5 to GW 2012.2 on
    SLES 11.3. Single PO system, with only 65 users.
    We have been experiencing 10 second hangs/delays the first time any GW
    address book functions are accessed. Some users are on the GW 2012.0.2
    client, others are still on the GW 8.0.3 client, all experiencing the 10
    second delay issue. We did not experience this before the migration to
    GW 2012.
    Testing indicates that the issue is due to shared address books.
    The 10 second delay always occurs the *first* time we access an address
    book function after starting the GroupWise client. For example, once
    the GroupWise client is newly started, if I open the address book, it
    takes 10 seconds to open. If I then create a new mail or appointment,
    while adding recipients to an e-mail, selecting a new addressbook from
    the address selector drop-down menu takes almost 10 seconds for the
    drop-down menu to respond to first being clicked on.
    Once I've accessed an address book function, though, accessing that
    function is much quicker on successive uses. But it does take doing
    each of those things once (suffering through the 10 hang) before they
    speed up. If a user makes the mistake of closing GroupWise, I'm back to
    square one with the first use of each of those address book functions
    being slow again.
    *BUT*, if I delete all address books that have been shared with me,
    there is no 10 second delay, even after restarting the GroupWise client.
    No slow access to any address book feature on first use.
    Unfortunately, we use shared address books very heavily, so deleting
    them for all of my users is not a solution.
    Besides running PO/user maintenance, I've looked at possible
    communications or DNS issues with no luck.
    Any ideas what's going on or how to fix it?
    Thanks,
    -Greg
    former e-mail for posting:
    [email protected]

    Originally Posted by gtn
    We have been experiencing 10 second hangs/delays the first time any GW
    address book functions are accessed. Some users are on the GW 2012.0.2
    client, others are still on the GW 8.0.3 client, all experiencing the 10
    second delay issue. We did not experience this before the migration to
    GW 2012.
    Testing indicates that the issue is due to shared address books.
    We have been dealing with this same if not similar sounding issue, opened a SR, and engineering is looking into it. For us it also impacts message compose ( address completeion ) as well as opening mail. We have yet to identify a workaround. What we see is "roughly" a 3 second delay per shared address book, occuring intermittently after a period of the client being idle. We also see on the POA that periodically the client will login to these shared accounts, but instead of those logins happening quickly ( sub 1 second for all of them combined ).
    This is not a constant problem for all users with the 2012 client, and seems to run in fits for a given user. We see it, perhaps 1 -3 times a day for a given user.
    If you enable Verbose logging on the POA ( via the HTTP console ) and look for the IP address of the workstation with the problems, you should see a pattern of logins as follows:
    Code:
    1204poa.028:18:41:32 F059 C/S Login Windows ::GW Id=Kxxxxr :: 192.168.1.110
    1204poa.028:18:41:35 F059 C/S Login Windows ::GW Id=Sxxxxk :: 192.168.1.110
    1204poa.028:18:41:38 F059 C/S Login Windows ::GW Id=Exxxxr :: 192.168.1.110
    1204poa.028:18:41:41 F061 C/S Login Windows ::GW Id=Sxxxxk :: 192.168.1.110
    1204poa.028:18:41:44 F051 C/S Login Windows ::GW Id=Kxxxxr :: 192.168.1.110
    1204poa.028:18:41:47 F061 C/S Login Windows ::GW Id=Dxxxxr :: 192.168.1.110
    1204poa.028:18:41:50 F061 C/S Login Windows ::GW Id=Kxxxxr :: 192.168.1.110
    ( Using something like grep -i "GW Id" 1204poa.??? | grep -i "Login Windows" | grep x.x.x.x <== IP of the workstation when in /var/log/no*/gr*/POA_Log_Folder )
    Note the 3 second delay between each of the shared account logins. This typifies the problem we are seeing. Under normal circumstances you would see these all happening with the same time stamp. Perhaps you can confirm this is the same looking issue.
    I'll keep you apprised of our progress.
    -- Bob

  • DAQ Monitor Equivalent function in NIDAQmx

    Hello,
    What is the equivalent function of DAQ_Monitor() in the NIDAQmx.
    I want to read the ADCs into a buffer and perform DAQ_Monitor operation upon the buffer at regular interval.
    Any suggestions??
    regards,
    Dwivedi

    There isn't really a one-to-one mapping between Traditional Legacy VIs
    and NI-DAQmx VIs. So can you explain a little more what you are trying
    to accomplish? By "perform DAQ_Monitor()" do you mean reading (grabbing
    samples from) the buffer at regular interval or just seeing what is in
    the buffer? In the latter case, are you interested in just the number
    of samples or the actual samples?

  • Any function equivalent to pthread_delay_np?

    I need a function to delay a thread process for a certain time. pthread_delay_np is used for this purpose on other UNIX platforms(HP and AIX). I did not find this function on Solaris. I am wondering if there is any equivalent function that can be used in place of pthread_delay_np.
    Thanks,
    Lan

    Hi Lan,
    sleep() used in a multithreaded program will suspend only the calling thread from execution . So I believe you can go ahead and use it .
    sleep() takes time in seconds as argument . If you want more precicion of time you can use usleep() or nanosleep().
    alarm() semantics is different in Solaris for pthread library and Solaris thread library . If you link with pthread library you will get per-process semantics whereas with Solaris thread library you will get per-LWP semantics (not per user thread) .
    From your mails , it looks like you are not using alarm() in your program . So I believe sleep() should solve your problem .
    Thanks,
    Prajeesh

  • To_numer function return error in pl/sql

    Hello,
    I don't have a prob when running select to_number('1234.56') from dual, the numer contains digit decimal
    But this stm return error Invalid number in procedure unless I use to_number('1234.56','9999999.99')
    Please help me out.
    Do I have to set parameter in DB ?
    BTW: my NLS_NUMERIC_CHARACTER is set to '.,'
    Thanks.

    to_numer function return error in pl/sql
    hlthanh wrote:
    Hello,
    I don't have a prob when running select to_number('1234.56') from dual, the numer contains digit decimal
    But this stm return error Invalid number in procedure unless I use to_number('1234.56','9999999.99')
    Please help me out.
    Do I have to set parameter in DB ?
    BTW: my NLS_NUMERIC_CHARACTER is set to '.,'
    Thanks.Handle:      hlthanh
    Status Level:      Newbie
    Registered:      Mar 7, 1999
    Total Posts:      94
    Total Questions:      60 (38 unresolved)
    so many questions & so few answers.
    How SAD!

  • Function Overloading concept in PL/SQL

    hi all,
    do we have Function Overloading concept in PL/SQL? If so, how to implement it? can anybody help me out with an example?

    Yep.
    SQL> create or replace
      2  package test_package as
      3
      4     function blah(param IN NUMBER) return number;
      5     function blah(param IN DATE) return number;
      6     function blah(param IN VARCHAR2) return number;
      7
      8     -- or
      9
    10     function blah(param IN NUMBER) return date;
    11     function blah(param IN NUMBER) return varchar2;
    12     function blah(param IN NUMBER) return char;
    13
    14  end test_package;
    15  /
    Package created.

Maybe you are looking for