1. Well the obvious answer is to look see if its there.
2. See 1
3 yes.
Your statements sound like you have already been shown/explained answers.
So Start with the first problem you need to find out if the data is new data or not..
Go with that.. attempt some answers, post your ideas..
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
First off this is in the wrong forum :( -- Please post these question to SQL in the future.
Secondly what version of SQL is this? In SQL 2005 they introduced "Delete Top" so the mechanism I would use for going about this task is quite different depending on the version.
Third, can you post sample data? If not at least give the table structure. A unique row identifier may come in to play here.
Once you get #2/#3 answered i'll give it a go.
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
Mostly I'm looking for an answer to sum up the population of any given country, generating a two column table, COUNTRY and POPULATION respectively. I'm guessing using the Sum() function? I'm lost here fellas :P
Something along the lines of this should work
Select Max(Country.Name) As CName, Sum(Province.Population) As TotalPop
From Country Left Join City On (Country.IDCountry = City.IDCountry)
Left Join Province On (City.IDCity = Province.IDCity)
Group By Country.IDCountry
Order By CName
(I chose the grouping off the ID because i assumed the ID's were unique and not specified in the table structure you posted. The way I chose to group the records will show you two records for "USA" in the Country table instead of aggregating them together, that way you can visually see if a country has a repeating name...if my assumption is correct)
The problem here is that if you have duplicate records on the 2 parent tables and have to delete them, then this could possibly change the values you get for the total population.
Given the parameters of your assignment my *guess* is that none of the countries repeat themselves. I am willing to bet that the cities do repeat themselves, and all of the population records in the Province table are linked to the City table on records that have the "master bit" set true, that way you can't accidently delete the duplicate record that has associated child records. By doing this the professor knows exactly what the totals should look like regardless of what record you deleted, because you have to maintain the records with the bit set....
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
Liz, once again your answers are of no use to anyone but your ego.
What I'm asking for is generic pseudo-code. Your crappy list hardly answers any single one of my questions.
Well perhaps its your ego thats got the problem..
You showed NO effort at all, but now feel its fine and dandy to poke at someone else.. This is an exceptionally childish attitude
You didnt ask for pseudo-code, you didnt really ask for anything.
I asked you to try something, for which you didnt bother but come back with insults.
my "crappy" list gives you more info than you put in effort for your first post.
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Well perhaps its your ego thats got the problem..
You showed NO effort at all, but now feel its fine and dandy to poke at someone else.. This is an exceptionally childish attitude
You didnt ask for pseudo-code, you didnt really ask for anything.
I asked you to try something, for which you didnt bother but come back with insults.
my "crappy" list gives you more info than you put in effort for your first post.
After looking at his thread history I agree
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735