VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 1[2] ]
Subject: Re: smá spurning


Author:
Hjálmtýr
[ Next Thread | Previous Thread | Next Message | Previous Message ]
Date Posted: 15:20:15 01/Oct/2007
In reply to: 's message, "smá spurning" on 01:55:38 01/Oct/2007

>Ef við höfum t.d. eftirfarandi niðurstöðu úr töflu sem
>er útkoma úr fyrirspurn
>
>epli
>epli
>banani
>appelsína
>
>er hægt að finna að það er epli sem kemur oftast út?

Þú vilt þá finna max(count(*)), en það er ekki hægt að hafa hreiðraða samsafnsvirkja. Það er sýnidæmi í bókinni,
Q37 á bls. 161, sem sýnir eitthvað svipað (nema min(avg(.))). Lausnin þar (efst á bls. 162) virkar reyndar ekki
í PostgreSQL, þar sem ekki er hægt að nota töflunafnið Temp í where-hlutanum. Það er hægt að leysa það með því að
endurtaka select-skipunina. Til dæmis:

select temp.rating, temp.avgage
from (select s.rating, avg(s.age) as avgage
from sailors s
group by s.rating) as temp
where temp.avgage = (select min(temp2.avgage2) from (select s2.rating, avg(s2.age) as avgage2
from sailors s2
group by s2.rating) as temp2)

[ Next Thread | Previous Thread | Next Message | Previous Message ]


[ Contact Forum Admin ]


Forum timezone: GMT+0
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.