时间:2021-05-24
mysql> use test;
Database changed
mysql> CREATE TABLE shop (
-> article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
-> dealer CHAR(20) DEFAULT '' NOT NULL,
-> price DOUBLE(16,2) DEFAULT '0.00' NOT NULL,
-> PRIMARY KEY(article, dealer));
Query OK, 0 rows affected (0.13 sec)
mysql> INSERT INTO shop VALUES
-> (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),
-> (3,'C',1.69),(3,'D',1.25),(4,'D',19.95);
Query OK, 7 rows affected (0.03 sec)
Records: 7 Duplicates: 0 Warnings: 0
mysql> select * from shop;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0001 | A | 3.45 |
| 0001 | B | 3.99 |
| 0002 | A | 10.99 |
| 0003 | B | 1.45 |
| 0003 | C | 1.69 |
| 0003 | D | 1.25 |
| 0004 | D | 19.95 |
+---------+--------+-------+
7 rows in set (0.06 sec)
mysql> select article,max(price) from shop group by article
-> ;
+---------+------------+
| article | max(price) |
+---------+------------+
| 0001 | 3.99 |
| 0002 | 10.99 |
| 0003 | 1.69 |
| 0004 | 19.95 |
+---------+------------+
4 rows in set (0.05 sec)
mysql> select article,max(price),dealer from shop group by article;
+---------+------------+--------+
| article | max(price) | dealer |
+---------+------------+--------+
| 0001 | 3.99 | A |
| 0002 | 10.99 | A |
| 0003 | 1.69 | B |
| 0004 | 19.95 | D |
+---------+------------+--------+
4 rows in set (0.00 sec)
mysql> select article,dealer,price from shop s1
-> where price=(select max(s2.price) from shop s2
-> where s1.article=s2.article);
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0001 | B | 3.99 |
| 0002 | A | 10.99 |
| 0003 | C | 1.69 |
| 0004 | D | 19.95 |
+---------+--------+-------+
4 rows in set (0.01 sec)
mysql> select s1.article,dealer,s1.price
-> from shop s1
-> join(
-> select article,max(price) as price from shop
-> group by article) as s2
-> on s1.article = s2.article and s1.price = s2.price;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0001 | B | 3.99 |
| 0002 | A | 10.99 |
| 0003 | C | 1.69 |
| 0004 | D | 19.95 |
+---------+--------+-------+
4 rows in set (0.05 sec)
mysql> select s1.article,s1.dealer,s1.price from shop s1
-> left join shop s2 on s1.article=s2.article and s1.price select s1.article,s1.dealer,s1.price,s2.* from shop s1 left join shop s2
on s1.article=s2.article and s1.price
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
一、双重夹击,围城中经销商面临的尴尬线上:互联网vs电商侵蚀传统经销商利益对于传统经销商而言,互联网B2B平台的到来,加速了信息的流通,价格信息更加透明,购买渠
对于第一次进入电器商业领域的伙伴来说,最初成为经销商是个好选择,现在很多经销商都是经销商,而且生意很好,那么很多经销商的流程是什么?1、参加拼写战斗流通业者首先
1经销商/服务提供商信息内容维护保养包含经销商和服务提供商的基础信息维护保养,服务提供商清算占比维护保养,经销商合同价维护保养。1.1建立经销商/服务提供商进到
经销商:是经营某种产品的客商户。一般与厂家签定销售合同,预付一定的保证金,货款的支付跟谈判技巧有关,销售价格由经销商决定,厂家不直接干预价格的确定,产品销售情况
淘宝分销服务平台代销商有经销商与分销区别,实际的差别从界定的详细介绍就可以看出去1、经销商经销商类似批發,代销商根据分销系统提交订单后转化成订货单,经销商送货给