If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > how to display 2 columns with the same column name but different value?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-11-10, 08:19
aisderu aisderu is offline
Registered User
 
Join Date: Feb 2010
Posts: 1
how to display 2 columns with the same column name but different value?

detailed problem is as follow:

Here is a schema about battleships and the battles they fought in:

Ships(name, yearLaunched, country, numGuns, gunSize, displacement)
Battles(ship, battleName, result)

A typical Ships tuple would be:


('New Jersey', 1943, 'USA', 9, 16, 46000)

which means that the battleship New Jersey was launched in 1943; it belonged to the USA, carried 9 guns of size 16-inch (bore, or inside diameter of the barrel), and weighted (displaced, in nautical terms) 46,000 tons. A typical tuple for Battles is:


('Hood', 'North Atlantic', 'sunk')

That is, H.M.S. Hood was sunk in the battle of the North Atlantic. The other possible results are 'ok' and 'damaged'.

Write the following queries:

1. List all the pairs of countries that fought each other in battles. List each pair only once, and list them with the country that comes first in alphabetical order first.

2. For the battle of Surigao Strait, for each country engaged in that battle (had one or more battleships participating), give the number of its battleships that were sunk. Note: this question is very tricky. In particular, you need to deal with the (historical) case that a country engaged in the battle but did not have any ships sunk.
Reply With Quote
  #2 (permalink)  
Old 02-11-10, 10:55
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,258
What have you done so far (show the query)
where do you get stuck?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On