I have this sql
Essentially there are a number of distributors per country. Up till now the latest distributor added (distributorid is an autonumber) was guranateed to have the latest version number. and the above code worked
now new distributors are being added but who's version number is lower.
EG
The code above would bring back this view:
Before you would be guaranteed that the version number on these distributor would be the latest/current version.
BUT now someone is coming along and adding in new distributors who are based off older versions and its screwing up the view
(new distributor added)
distributorid=10001
country=3
version=7.1
So I would prefer country ID 3 to use the distributor with the latest version number of any distributors in that country (I don't care which of the many distributors it is as long as its one with the latest version in that country - in this case it would be distributor 1232 who's version is 7.2 instead of 10001)
Code:
SELECT
max(d.distributorid),
c.countryid
FROM
distributor d,
country c
WHERE
d.countryid = c.countryid
and d.hassmbsb=1
group by
c.countryid
Essentially there are a number of distributors per country. Up till now the latest distributor added (distributorid is an autonumber) was guranateed to have the latest version number. and the above code worked
now new distributors are being added but who's version number is lower.
EG
The code above would bring back this view:
Code:
Distributorid | CountryID
10000 1 {this version is 7.3}
6662 2 {this version is 7.3}
1232 3 {this version is 7.2}
Before you would be guaranteed that the version number on these distributor would be the latest/current version.
BUT now someone is coming along and adding in new distributors who are based off older versions and its screwing up the view
(new distributor added)
distributorid=10001
country=3
version=7.1
Code:
Distributorid | CountryID
10000 1 {this d.version is 7.3}
6662 2 {this d.version is 7.3}
10001 3 {this d.version is 7.1}
So I would prefer country ID 3 to use the distributor with the latest version number of any distributors in that country (I don't care which of the many distributors it is as long as its one with the latest version in that country - in this case it would be distributor 1232 who's version is 7.2 instead of 10001)