.dsy:it.
Show 150 posts per page

.dsy:it. (http://www.dsy.it/forum/)
- Basi di dati ~ informatica triennale (http://www.dsy.it/forum/forumdisplay.php?forumid=211)
-- SQL Problem... (http://www.dsy.it/forum/showthread.php?threadid=37404)


Posted by vittorio on 17-01-2009 15:17:

Unhappy SQL Problem...

hola raga...mi potete dare una dritta su sta relazione?

/* chiavi primarie in grassetto e chiavi esterne sottolineate */

MACCHINISTA (CF, Nome, Cognome, Età)
TRENO (ID-Treno, Tipo(ES/IC/IR/D), Lunghezza, Ristorante(S/N))
PERCORRENZA (CF, ID-Treno, Nome-linea , Nr-fermate)

Determinare in SQL CF, Nome e Cognome dei macchinisti di treni euro star elencandoli in ordine alfabetico per cognome;

Determinare in SQL il CF dei macchinisti che percorrono il maggior numero di linee diverse


Posted by Gimmy on 18-01-2009 15:40:

io le ho risolte cosi...

select m.cf,nome,cognome
from macchinista m, treno t, percorrenza p
where m.cf=p.cf and t.id_treno=p.id_treno and tipo='es'
order by cognome

select m.cf
from macchinista m inner join percorrenza p on m.cf=p.cf
group by m.cf
having count(distinct nome_linea)>= all (select count(distinct nome_linea)
from macchinista m inner join percorrenza p on m.cf=p.cf
group by m.cf)


Posted by vittorio on 18-01-2009 16:03:

io inveve la prima l'ho risolta così:

SELECT m.cognome, m.nome, m.cf
FROM macchinista JOIN percorrenza ON (macchinista.cf = percorrenza.cf) JOIN treno ON (percorrenza.treno = treno.idtreno)
WHERE treno.tipo="ES"
ORDER BY macchinista.cognome

la seconda non l'ho ancora risolta...


Posted by Gimmy on 18-01-2009 16:14:

si è uguale, solo che tu hai fatto le join mentre io ho fatto il confronto fra chiavi esterne


Posted by vittorio on 18-01-2009 16:38:

Sì sì...esattamente...ma tu devi fare l'appello del 20?


Posted by Gimmy on 18-01-2009 16:49:

si perchè?


Posted by vittorio on 19-01-2009 10:11:

No, così chiedevo...hai visto il progetto?? ci sono molti dubbi inerenti ai turni di gioco. bah..


All times are GMT. The time now is 06:09.
Show all 7 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.