Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
153 views
in Technique[技术] by (71.8m points)

mysql - need to know if this is possible in SQL

I have sales orders with quotes against them however new quote revisions are made and sometimes the sales orders don't get updated. So i need to write query to find any orders that don't have the most updated quote.

Currently this is done in excel but i want to be able to run a query to get the same results.

MY SQL or SQL Server.

Table and fields
Sales order lines - sales order ID / current quote ID
Quotes - Quote ID

The sales order ID is a numerical field XXXXX. The quote ID fields are like 12345 and if a new revision is created it a new quote is added and called 12345-A it goes up alphabetically per revision.

What i want to see is

Sales order ID | Current Quote ID | Latest Quote ID
---------------|------------------|-----------------
53849          | 12345            | 12345-D

Please let me know if this is possible

Example Data

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is too long for a comment and is not an answer.

I am totally baffled by the question. Your sample results have something called a Sales Order ID with a value of 53849. I see no 53849 in the sample data. Of course, I might be missing it. But I can't search an image.

Then:

The quote ID fields are like 12345.

However, none of the values in the Quote ID field look like this.

The first four columns are not labelled, so you have not communicated what the data looks like or how to identify the "old" and "new" values.

I would recommend that you ask a new question, with clear sample data as a text table (and also a fiddle is very helpful). And clear desired results.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...