Avatar billede lars_hoeberg Praktikant
14. juni 2004 - 15:18 Der er 7 kommentarer og
2 løsninger

pluk de 4 højeste tal ud

Hej alle.

Hvordan plukker jeg, i en forespørgsel, de 4 højeste tal i en tabel ud, så jeg kun har de 4 tal i forespørgslen?

På forhånd tak.
- Lars -
Avatar billede terry Ekspert
14. juni 2004 - 15:18 #1
SELECT TOP 4 FROM YourTable ORDER BY TalFelt DESC
Avatar billede terry Ekspert
14. juni 2004 - 15:20 #2
SELECT TOP 4 * FROM YourTable ORDER BY TalFelt DESC
Avatar billede lars_hoeberg Praktikant
14. juni 2004 - 15:28 #3
Hvad så hvis jeg f.eks skal have den 5. højeste til den 8. højeste?
Avatar billede overchord Nybegynder
14. juni 2004 - 16:48 #4
SELECT TOP 3 * FROM DinTabel WHERE ID<>(SELECT TOP 5 ID FROM dintabel) ORDER BY Talfelt DESC.
Avatar billede terry Ekspert
14. juni 2004 - 20:28 #5
Thats another question isnt it :o)

If you have an ID (autonumber) in the table then overchords will work I think (not tested :o) ) but if you only have the tal field then I think this might work.

NOTE: This gives you the 5th to the 8th heighest (4 records) and ID is the tal field

SELECT TOP 4 * FROM Tabel WHERE ID NOT IN  (SELECT TOP 4 ID FROM tabel ORDER BY ID DESC) ORDER BY ID DESC
Avatar billede terry Ekspert
15. juni 2004 - 14:38 #6
can you use these answers Lars?
Avatar billede terry Ekspert
15. juni 2004 - 14:42 #7
Lars, I notice you have a couple of old open questions for over 400 points. If you arent happy with the help you received then you could place an answer yourself and get the points back :o)
Avatar billede lars_hoeberg Praktikant
18. juni 2004 - 11:54 #8
Sorry, i've been away for a couple of days. Hop it's allright. Thank for your help
Avatar billede terry Ekspert
18. juni 2004 - 17:34 #9
no problem at all Lars!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester