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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:34:41+00:00 2026-05-25T02:34:41+00:00

I have issues in query: priceDeatil ProductCode BusinessUnit price DateFrom DateTo 10001 ORB 12.00

  • 0

I have issues in query:

 priceDeatil 
 ProductCode  BusinessUnit  price   DateFrom     DateTo
  10001         ORB          12.00   12-08-2011   31-09-2015
  10001         ORB          21.00   01.08-2011   15-11-2011
  10002         ORB          31.00   01.04-2011   15-08-2012
  10003         ORB          42.00   01.05-2011   15-08-2012

My query is:

 SELECT     BusinessUnit, ProductCode,  DateFrom, DateTo, Price
 FROM         WMPriceDetail
 WHERE     (DateFrom < 'Sep 01 2011') AND (DateTo > 'Sep 01 2011' OR DateTo = '')
 ORDER BY ProductCode

This return

   priceDeatil 
 ProductCode  BusinessUnit  price   DateFrom     DateTo
  10001         ORB          12.00   12-08-2011   31-09-2015
  10001         ORB          21.00   01.08-2011   15-11-2011
  10002         ORB          31.00   01.04-2011   15-08-2012
  10003         ORB          42.00   01.05-2011   15-08-2012

But Here productCode 10001 return two records; That time I want to get the Max Date i.e 12-08-2011 .

So desired result should be like this:

   priceDeatil 
 ProductCode  BusinessUnit  price   DateFrom     DateTo
  10001         ORB          12.00   12-08-2011   31-09-2015
  10002         ORB          31.00   01.04-2011   15-08-2012
  10003         ORB          42.00   01.05-2011   15-08-2012

How to write query for this situation?

  • 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-25T02:34:41+00:00Added an answer on May 25, 2026 at 2:34 am
     SELECT     BusinessUnit, ProductCode,  DateFrom, DateTo, Price FROM
     (SELECT    BusinessUnit, ProductCode,  DateFrom, DateTo, Price, 
     rank() over (PARTITION BY ProductCode ORDER BY DateFrom DESC) rank_num
     FROM  WMPriceDetail
     WHERE (DateFrom < 'Sep 01 2011') AND (DateTo > 'Sep 01 2011' OR DateTo = '') t 
     WHERE rank_num=1
     ORDER BY ProductCode
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a linq query that is causing some timeout issues. Basically, I have
I have 2 issues with below query 1) I want to append 'HDR' before
I have an nHibernate query issue that looks quite straight forward, but I can't
I have an issue with a my SQL query. I need to execute a
We're using SQL Server 2000 Query Analyser, and one issue we have is that
I'm having an issue getting a LINQ query to work. I have this XML:
I have issues with NSUserDefaults and I don't quite understand what is going on.
We have issues within an application using a state machine. The application is implemented
I still have issues reading UML diagrams. Just looking at the Builder pattern http://en.wikipedia.org/wiki/Builder_pattern
I have some issues with a PHP file that is not working properly. The

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.