| |

VerySource

 Forgot password?
 Register
Search
Author: donkey_ngacn

A SQL statement query problem (query minimum value) (urgent)

[Copy link]

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-3-8 12:00:01
| Show all posts
That's it, thank you
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-5-27 11:00:01
| Show all posts
I feel that I only want to see the result data I want, I do n’t value how the data comes ~
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-29 21:00:01
| Show all posts
select a.id as "a.id", a.name as "a.name", c.id as "b.id", c.aid as "b.aid", c.price as "b.price" from a
right join (
select top 1 * from b order by price asc) c
on a.id = c.aid
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-7 13:45:02
| Show all posts
我是杀人狂is the simplest
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-10 12:15:02
| Show all posts
我是杀人狂does not work, the price of other groups may also be the minimum value of other groups,mydriveris simple and fast!
top! ! ! ! ! ! ! ! ! ! ! ! ! !
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-6-12 02:45:01
| Show all posts
mark!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-17 18:00:02
| Show all posts
select *
from a a
inner join b b
on a.id=b.aid
and b.id in
(
select min(b.id) from b
where b.price in
(
select min(price) from b
)
)
;
Reply

Use magic Report

0

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-6-28 13:30:01
| Show all posts
SELECT *
FROM A
INNER JOIN B
ON a.id=b.aid
WHERE b.price=
(SELECT MIN(prics)
FROM B)
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Mexico

Post time: 2020-7-2 20:30:01
| Show all posts
我是杀人狂is optimal, but the join needs to be changed to left join
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-2 21:00:01
| Show all posts
declare @A table(id int,name varchar(50))
declare @B table(id int,AID int,price int)

insert @A select 1,'DEMO'
union all
select 2,'DEMO2'

insert @B select 1,1,30
union all select 2,1,32
union all select 3,1,26

select top 1 A.id, A.name, B.id, B.AID, B.price
from @B B
join @A A on A.id=B.AID
order by price
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list