Results 1 to 6 of 6

Thread: [RESOLVED] Need help on sqlce select statement

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    London United Kingdom
    Posts
    334

    Resolved [RESOLVED] Need help on sqlce select statement

    hi iam having error with this select statement which works with sql server "select top 1 holidaypay from shiftpaid order by paidid desc". The error is the top, so if anyone could help. What I want to do is to select a column from a last row in a table. Thanx

  2. #2
    Member
    Join Date
    Feb 2007
    Location
    Netherlands
    Posts
    43

    Re: Need help on sqlce select statement

    Try select top(1) holidaypay from shiftpaid order by paidid desc. If i remember correctly in sqlce you need to use the () for some reason.

  3. #3
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Need help on sqlce select statement

    Hi,
    pretty sure 'top' is not supported - take a look at 'books online'

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  4. #4
    Member
    Join Date
    Feb 2007
    Location
    Netherlands
    Posts
    43

    Re: Need help on sqlce select statement

    It is since 3.5, so provided u are using the latest version it should work, check this link

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Need help on sqlce select statement

    Another way to do that without top would be

    Code:
    select holidaypay from shiftpaid
        where paidid=(select max(paidid) from shiftpaid)
    Although whether CE supports sub-queries in that fashion is a guess on my part...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Need help on sqlce select statement

    Now that I look at it, since you only want a single field, another way to do this would be to use ExecuteScalar with the query:

    SELECT Holidaypay FROM shiftpaid Order BY paidid desc

    This would return the first column in the SELECT statement from the first row in the records returned. With the ORDER clause in there, the first row will be the one you want, and with HolidayPay being the only field, then that will be the data.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width