Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

SQL Management Studio- kako izracunati prosek

[es] :: MS SQL :: SQL Management Studio- kako izracunati prosek

[ Pregleda: 6364 | Odgovora: 10 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Fnatic
Subotica

Član broj: 308543
Poruke: 2
*.dynamic.isp.telekom.rs.



Profil

icon SQL Management Studio- kako izracunati prosek07.11.2012. u 21:23 - pre 138 meseci
Pozdrav svima treba mi pomoc oko jednog zadatka .
Izračunati prosek ocena po ID Predmeta
Prikazati u rezultat kolonu PredmetID i sumu ocena, grupisati po koloni PredmetID iz tabele StudentPredmet
Izračunati prosek ocena za svakog studenta

Selektovati kolone: StudentPredmet.StudentID, Student.Ime, Student.Prezime, Ocena
Koristeći tabele: dbo.StudentPredmet, dbo.Student
Rezultat prikazati desc nad kolonom StudentPredmet.StudentID.

Znam da napravim Tabele i poglede ali ne znam da izracunam sto se trazi .
SQL Management Studio koristim.
Perlaska
Prikačeni fajlovi
 
Odgovor na temu

Dusan Kondic
Programer
ZR "Parametar" Ljubovija
Ljubovija

Član broj: 49961
Poruke: 225
*.adsl-a-4.sezampro.rs.

Sajt: www.drinacoding.com


+14 Profil

icon Re: SQL Management Studio- kako izracunati prosek08.11.2012. u 11:31 - pre 138 meseci
Možda nešto ovako:
Code:

SELECT dbo.Student.Ime, dbo.Student.Prezime, dbo.Student.BrojIndexa, dbo.Student.Telefon, 
dbo.StudentPredmet.PredmetID, AVG(dbo.StudentPredmet.Ocena) AS SrednjaOcena
FROM dbo.Student INNER JOIN dbo.StudentPredmet ON dbo.Student.SudentID = dbo.StudentPredmet.StudentID
GROUP BY dbo.Student.Ime, dbo.Student.Prezime, dbo.Student.BrojIndexa, dbo.Student.Telefon, dbo.StudentPredmet.PredmetID
ORDER BY dbo.Student.SudentID DESC
 
Odgovor na temu

Fnatic
Subotica

Član broj: 308543
Poruke: 2
*.dynamic.isp.telekom.rs.



Profil

icon Re: SQL Management Studio- kako izracunati prosek08.11.2012. u 16:32 - pre 138 meseci
Hvala na pomoci , znacu sad da uradim .




Svako dobro
Perlaska
 
Odgovor na temu

VincentValentine
nezaposlen

Član broj: 327590
Poruke: 6
*.dynamic.isp.telekom.rs.



+1 Profil

icon Re: SQL Management Studio- kako izracunati prosek28.02.2015. u 11:03 - pre 110 meseci
Citat:
Dusan Kondic:
Možda nešto ovako:
Code:

SELECT dbo.Student.Ime, dbo.Student.Prezime, dbo.Student.BrojIndexa, dbo.Student.Telefon, 
dbo.StudentPredmet.PredmetID, AVG(dbo.StudentPredmet.Ocena) AS SrednjaOcena
FROM dbo.Student INNER JOIN dbo.StudentPredmet ON dbo.Student.SudentID = dbo.StudentPredmet.StudentID
GROUP BY dbo.Student.Ime, dbo.Student.Prezime, dbo.Student.BrojIndexa, dbo.Student.Telefon, dbo.StudentPredmet.PredmetID
ORDER BY dbo.Student.SudentID DESC






Column 'dbo.StudentPredmet.StudentID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
 
Odgovor na temu

Dusan Kondic
Programer
ZR "Parametar" Ljubovija
Ljubovija

Član broj: 49961
Poruke: 225
*.adsl-1.sezampro.rs.

Sajt: www.drinacoding.com


+14 Profil

icon Re: SQL Management Studio- kako izracunati prosek28.02.2015. u 11:50 - pre 110 meseci
Pišem napamet, ali ovo bi trebalo da radi:
Code:

SELECT dbo.Student.StudentID, dbo.Student.Ime, dbo.Student.Prezime, dbo.Student.BrojIndexa, dbo.Student.Telefon, 
MAX(dbo.StudentPredmet.PredmetID) AS PredmetID, AVG(dbo.StudentPredmet.Ocena) AS SrednjaOcena
FROM dbo.Student INNER JOIN dbo.StudentPredmet ON dbo.Student.SudentID = dbo.StudentPredmet.StudentID
GROUP BY dbo.Student.StudentID, dbo.Student.Ime, dbo.Student.Prezime, dbo.Student.BrojIndexa, dbo.Student.Telefon
ORDER BY dbo.Student.StudentID DESC
 
Odgovor na temu

VincentValentine
nezaposlen

Član broj: 327590
Poruke: 6
*.dynamic.isp.telekom.rs.



+1 Profil

icon Re: SQL Management Studio- kako izracunati prosek28.02.2015. u 14:05 - pre 110 meseci
select dbo.Student.Ime, dbo.Student.Prezime,
avg(dbo.StudentPredmet.Ocena) as srednjaOcena
from dbo.Student INNER JOIN dbo.StudentPredmet on dbo.Predmet.PredmetID = dbo.StudentPredmet.PredmetID
group by dbo.Student.Ime, dbo.Student.Prezime
order by dbo.Student.Ime DESC

gde gresim kada racunam prosecnu po ocenuku
 
Odgovor na temu

plague
Software Developer
Auckland, NZ

Član broj: 46734
Poruke: 623
..0.252.27.dyn.cust.vf.net.nz.



+373 Profil

icon Re: SQL Management Studio- kako izracunati prosek28.02.2015. u 15:18 - pre 110 meseci
Join uslov ne valja:
Code (sql):

INNER JOIN dbo.StudentPredmet ON dbo.Student.StudentID = dbo.StudentPredmet.StudentID
 
 
Odgovor na temu

VincentValentine
nezaposlen

Član broj: 327590
Poruke: 6
*.dynamic.isp.telekom.rs.



+1 Profil

icon Re: SQL Management Studio- kako izracunati prosek28.02.2015. u 16:25 - pre 110 meseci
Izračunati prosek ocena po ID Predmeta
Prikazati u rezultat kolonu PredmetID i sumu ocena, grupisati po koloni PredmetID iz tabele StudentPredmet
Po predmetuID bi trebalo da bude ovako, ali opet prijavljuje gresku


SELECT dbo.Student.StudentID, dbo.Student.Ime, dbo.Student.Prezime, dbo.Student.BrojIndexa, dbo.Student.Telefon,
SUM(dbo.StudentPredmet.Ocena) AS SumaOcena, AVG(dbo.StudentPredmet.Ocena) AS SrednjaOcena
FROM dbo.Student INNER JOIN dbo.ProfesorPredmet ON dbo.Predmet.PredmetID = dbo.ProfesorPredmet.PredmetID
GROUP BY dbo.Student.StudentID, dbo.Student.Ime, dbo.Student.Prezime, dbo.Student.BrojIndexa, dbo.Student.Telefon
ORDER BY dbo.Predmet.PredmetID DESC
 
Odgovor na temu

VincentValentine
nezaposlen

Član broj: 327590
Poruke: 6
*.dynamic.isp.telekom.rs.



+1 Profil

icon Re: SQL Management Studio- kako izracunati prosek28.02.2015. u 17:27 - pre 110 meseci

ok, ovaj jedan sam uspeo. ovo je prosek ocena po studentId desc

select dbo.Student.Ime, dbo.Student.Prezime, dbo.StudentPredmet.StudentID,
avg(dbo.StudentPredmet.Ocena) as srednjaOcena
from dbo.Student INNER JOIN dbo.StudentPredmet ON dbo.Student.StudentID = dbo.StudentPredmet.StudentID
group by dbo.Student.Ime, dbo.Student.Prezime, dbo.StudentPredmet.StudentID
order by dbo.StudentPredmet.StudentID DESC


jos prosek ocena po ID Predmeta
Prikazati u rezultat kolonu PredmetID i sumu ocena, grupisati po koloni PredmetID iz tabele StudentPredmet
koristeci
tabele dbo.StudentPredmet, dbo.Student
tabele dbo.StudentPredmet, dbo.Student
 
Odgovor na temu

Dusan Kondic
Programer
ZR "Parametar" Ljubovija
Ljubovija

Član broj: 49961
Poruke: 225
*.adsl-1.sezampro.rs.

Sajt: www.drinacoding.com


+14 Profil

icon Re: SQL Management Studio- kako izracunati prosek02.03.2015. u 12:31 - pre 110 meseci
Ako sam dobro razumeo, potreban ti je prosek ocena svakog studenta iz svakog predmeta. U tom slučaju samo u GROUP BY klauzulu dodaj i polje PredmetID a pošto ćeš siguno želeti da prikažeš i naziv predmeta, JOIN-uj tabelu sa predmetima i dodaj naziv predmeta u SELECT i u GROUP BY klauzulu.
Čemu služi suma ocena?
 
Odgovor na temu

Cat23
Subotica,Srbija

Član broj: 326718
Poruke: 22
*.dynamic.isp.telekom.rs.



+17 Profil

icon Re: SQL Management Studio- kako izracunati prosek06.03.2015. u 11:58 - pre 110 meseci
Pozz svima.
Sto se mene tice ovo je resenje za prosek ocena po ID Predmetu,stim sto on trazi i da se u novoj kolini prikaze suma pa sam i to ubacila.

select dbo.Predmet.PredmetID,
avg(dbo.StudentPredmet.Ocena) as ProsekOcena,
SUM(dbo.StudentPredmet.Ocena) as SumaOcena
from dbo.Predmet inner join dbo.StudentPredmet
on dbo.Predmet.PredmetID = dbo.StudentPredmet.PredmetID
group by dbo.Predmet.PredmetID

Sto se tice drugog zadatka ja sam napravila ovako

select dbo.StudentPredmet.StudentID,dbo.Student.Ime,dbo.Student.Prezime,
AVG(dbo.StudentPredmet.Ocena) as ProsekStudenta
from dbo.Student inner join dbo.StudentPredmet
on dbo.Student.StudentID=dbo.StudentPredmet.StudentID
group by dbo.StudentPredmet.StudentID,dbo.Student.Ime,dbo.Student.Prezime
order by dbo.StudentPredmet.StudentID desc

 
Odgovor na temu

[es] :: MS SQL :: SQL Management Studio- kako izracunati prosek

[ Pregleda: 6364 | Odgovora: 10 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.