Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7419851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:08:29+00:00 2026-05-29T08:08:29+00:00

I have a table in MSSQL as below : I want to create a

  • 0

I have a table in MSSQL as below :

enter image description here

I want to create a sql to select last bid record grouped by each productID.

So the result will be 3 records (row 13, row 15 and row 17).

My current sql is something like this :

select top 1 * 
from Bid 
order by bidDate desc
group by productID

There is an error shown :

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'group'.

Anyone can help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:08:29+00:00Added an answer on May 29, 2026 at 8:08 am

    The correct syntax near group by may be, unless you are in mysql, because you can’t SELECT * in a GROUP BY query.

    To solve your problem you can:

    SELECT 
        B.*
    FROM
        (
        SELECT 
            MAX(bidDate) maxDate,
            productID
        FROM
            Bid
        GROUP BY
            productID
        ) Q INNER JOIN Bid B
        ON Q.maxDate = B.bidDate
        AND Q.productID = B.productID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL table written in MSSQL: create table [action] ( action_id bigint
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a organization name table with the following structure given below: CREATE TABLE
I have a simple table as below. CREATE TABLE `stats` ( `id` int(11) NOT
I have a table that was created using this mysql statement below. CREATE TABLE
I have a table as below, I'm having trouble getting the results I want.
I have a table in a MSSQL database that looks like this: Timestamp (datetime)
Say I have an MSSQL table with two columns: an int ID column that's
I have to migrate a table from MSSQL Server to MySql. The problem is
I have a table ClassAttendance and I'm using MSSQL 2005 studentID attendanceDate status -------------------------------------

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.