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 8988791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:05:34+00:00 2026-06-15T22:05:34+00:00

Below is my Query. This query is returning the following result set shown below

  • 0

Below is my Query. This query is returning the following result set shown below in the image Result Set
But i want unique rows. How can i get unique rows?

Select
     distinct (tbl_Contract.ContractID),
     Tbl_Contract.KeyWinCountNumber,
     Tbl_Contract.ContractNumber,
     Tbl_Contract.ContractDate,
     Tbl_CountryFrom.CountryFromName,
     Tbl_CountryTo.CountryToName,
     tbl_Port.PortName,
     Tbl_Contract.Vans,
     Tbl_Contract.ContractID,
     Tbl_Item.ItemName,
     Tbl_Brand.BrandName,
     Tbl_Seller.SellerName,
     Tbl_Count.CountName,
     Tbl_Buyer.BuyerName

     from Tbl_Contract

     inner join Tbl_CountDetail
     on
     Tbl_CountDetail.ContractId = Tbl_Contract.ContractID
     inner join Tbl_Item
     on
     Tbl_Contract.ItemID = Tbl_Item.ItemID
     inner join Tbl_Brand
     on
     Tbl_Brand.BrandID = Tbl_Contract.ContractID
     inner join Tbl_Count
     on
     Tbl_CountDetail.CountId = Tbl_Count.CountID
     inner join Tbl_Seller 
     on
     Tbl_Seller.SellerID = Tbl_Contract.SellerID
     inner join Tbl_Buyer
     on
     Tbl_Buyer.BuyerID = Tbl_Contract.BuyerID
     inner join Tbl_CountryFrom
     on
     Tbl_CountryFrom.CountryFromID = Tbl_Contract.CountryFromID
     inner join Tbl_CountryTo
     on
     Tbl_CountryTo.CountryToID = Tbl_Contract.CountryToID
     inner join tbl_Port
     on
     tbl_Port.PortID = Tbl_Contract.PortID
  • 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-06-15T22:05:35+00:00Added an answer on June 15, 2026 at 10:05 pm

    Distinct by ContractId?

    You can use ROW_NUMBER with PARTITION BY ContractId and select only the first of each group:

    WITH CTE AS
    (
        SELECT C.*,
          ROW_NUMBER() OVER (PARTITION BY ContractId Order By ContractDate DESC)AS RN
        FROM Tbl_Contract C
    )
    SELECT * FROM CTE WHERE RN = 1
    

    Note that you can add the joins in the cte without any problem. I’ve omitted them for improved readability.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using below query to count the daily result, but now I'm make it
I have the below Linq query that is returning the data but I need
This query is not returning any result as there seems to be an issue
I have below query I am trying to show message 'No SubSource for this
On the query below I keep getting this error: Cannot read the next data
I have written this query for retrieving data from mysql as below select FeedbackCode,EMailID,FeedbackDetail,
This might be a very simple thing. Check out the normal sql query below
The query below is not returning any results. I have copied it from a
The error message is kinda vague... The query below works on one server, but
I need help in returning values in a query. Consider my example below where

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.