|
-
Sep 19th, 2005, 10:08 AM
#1
Re: SQL top
Well since you are already going down the path of sub-query...
You need to do the TOP 3/ORDER BY TOTAIS - there is no way around that.
If you want them to then be ordered by CLASS DESCRIPTION, then I guess you put that in another SUBQUERY - order by class description...
Code:
SELECT * FROM (SELECT TOP 3 * FROM (...) ORDER BY TOTAIS DESC)
ORDER BY CLASSE
-
Sep 19th, 2005, 10:25 AM
#2
Thread Starter
Frenzied Member
Re: SQL top
Maybe like this,but the sort are not right,unless the syntax are not correct
VB Code:
sql1 = "Select Top 3 * From ( " & _
"select pontosind1 as Totais, classifind1 as Classifind, seccao1 as Secção, classe1 as Classe, designacao1 as Designação, nomesocio as Expositor, anilha1 as Anilha, gaiolaind1 as Gaiola, Sexo1 as Sexo" & _
" from exposicao " & _
" WHERE pontosind1 >= '88'" & _
" and (pontoseq1 = '' or pontoseq1 is null) " & _
" UNION ALL" & _
" select pontosind2, classifind2, seccao2, classe2, designacao2, nomesocio, anilha2, gaiolaind2, sexo2" & _
" from exposicao " & _
" WHERE pontosind2 >= '88'" & _
" and (pontoseq1 = '' or pontoseq1 is null) " & _
" UNION ALL" & _
" select pontosind3, classifind3, seccao3, classe3, designacao3, nomesocio, anilha3, gaiolaind3, sexo3" & _
" from exposicao " & _
" WHERE pontosind3 >= '88'" & _
" and (pontoseq1 = '' or pontoseq1 is null) " & _
" UNION ALL" & _
" select pontosind4, classifind4, seccao4, classe4, designacao4, nomesocio, anilha4, gaiolaind4, sexo4" & _
" from exposicao " & _
" WHERE pontosind4 >= '88'" & _
" and (pontoseq1 = '' or pontoseq1 is null)" & _
[B]" ORDER BY totais desc) " & _
" ORDER BY classe desc [/B] "
thanks
-
Sep 19th, 2005, 10:48 AM
#3
Re: SQL top
I said to add another sub-query - not sort the "primary sub-query".
Code:
sql1 = "Select * From (Select Top 3 * From ( " & _
"select pontosind1 as Totais, classifind1 as Classifind, seccao1 as Secção, classe1 as Classe, designacao1 as Designação, nomesocio as Expositor, anilha1 as Anilha, gaiolaind1 as Gaiola, Sexo1 as Sexo" & _
" from exposicao " & _
" WHERE pontosind1 >= '88'" & _
" and (pontoseq1 = '' or pontoseq1 is null) " & _
" UNION ALL" & _
" select pontosind2, classifind2, seccao2, classe2, designacao2, nomesocio, anilha2, gaiolaind2, sexo2" & _
" from exposicao " & _
" WHERE pontosind2 >= '88'" & _
" and (pontoseq1 = '' or pontoseq1 is null) " & _
" UNION ALL" & _
" select pontosind3, classifind3, seccao3, classe3, designacao3, nomesocio, anilha3, gaiolaind3, sexo3" & _
" from exposicao " & _
" WHERE pontosind3 >= '88'" & _
" and (pontoseq1 = '' or pontoseq1 is null) " & _
" UNION ALL" & _
" select pontosind4, classifind4, seccao4, classe4, designacao4, nomesocio, anilha4, gaiolaind4, sexo4" & _
" from exposicao " & _
" WHERE pontosind4 >= '88'" & _
" and (pontoseq1 = '' or pontoseq1 is null))" & _
" ORDER BY totais desc) " & _
" ORDER BY classe desc "
-
Sep 19th, 2005, 11:06 AM
#4
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|