HI! I've got a problem... Given the schema below I need to create an SQL query, but for some reason I think there is something wrong with it....

BRANCH(BRANCH-NAME, BRANCH-CITY, ASSETS)

Query: in what cities are the branches where the maximal bank assets are less than £200,000?

So I've come up with the following SQL query:

SELECT BRANCH-CITY
FROM BRANCH B,
(SELECT MAX(ASSETS) AS MAXASSETS, BRANCH-CITY
FROM BRANCH
GROUP BY BRANCH-CITY) MAXINFO
WHERE MAXINFO.BRANCH-CITY = B.BRANCH-CITY AND MAXINFO.MAXASSETS < 200000

Is this OK? Is there any other way of doing this?

looks good, minus joining on the city, not able to join on an id?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.