I am trying to build a sql query for an exam site and need to list the top scoring exams for a user, there can be multiple exams.
I have the following script in ASP that puts the results into a javascript function so they can be read by a cms system on another server. -
rs.Source = "select ID, Username, UserID, Test_Name, MAX(Grade) FROM testscores WHERE UserID = " & Session("sesUserID") & " AND Grade > 69 GROUP BY UserID,Test_Name ORDER BY CAST(Grade AS UNSIGNED)"
-
-
-
Response.write("moduleCertificates: function(){")
-
response.write(vbcrlf)
-
response.write ("return {")
-
-
rs.Open()
-
while not rs.eof
-
-
Dim testName_Short
-
Dim testName
-
-
testName = rs.Fields.Item("test_Name").Value
-
testName_Short = testName
-
testName_Short = replace(testName_Short, "Gold_", "")
-
testName_Short = replace(testName_Short, "Silver_", "")
-
testName_Short = replace(testName_Short, "Bronze_", "")
-
-
response.write("'" & testName_Short & "': ' https://testwww.sharpacademy.eu/certificate.swf?UID=" & rs.Fields.Item("UserID").Value &"&ID=" & rs.Fields.Item("ID").Value & "',")
-
response.write(vbcrlf)
-
-
rs.MoveNext
-
Wend
-
response.write ("};")
-
response.write(vbcrlf)
-
response.write ("}")
-
response.write(vbcrlf)
-
rs.Close
-
Set rs = Nothing
-
this returns one result per exam for the user but it is the first one in the database for the exam and user.
i only need to return the ID and UserID from the database.
Any help would be appreciated
3 1353
You're saying that query runs? I don't see how that's possible, there are syntax errors. You have fields in your SELECT that aren't in your GROUP BY or in an AGGREGATE function.
as far as i am aware i can group by 1 field, why would you want to group by multiple fields
You can group by 1 field if you use the rest of the fields in an aggregate function.
You would want to group by multiple fields if those fields represent the unique combination that you want to aggregate by.
When you do an aggregate query, every field in the SELECT has to be either in a group by or in an aggregate function. Otherwise, the database has no idea what value to select for the rest of the fields.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jim Heavey |
last post by:
Hello, I was wondering how I would go about attaching some Java script code
to a <asp:EditCommandColumn. If the user presses the "edit" link, then I
want to test other controls to see if any...
|
by: dhruba.bandopadhyay |
last post by:
Is it possible for JavaScript to access the DOM of ASP.NET Web/Server
Controls?
For example, I have a legacy HTML forms, controls, etc. If I convert
all
my HTML into Web Controls (by adding...
|
by: visionstate |
last post by:
Hi All,
I have used the following article to help me build a query 'on the
fly':
http://www.fontstuff.com/access/acctut17.htm
It's a very useful article and is exactly what I was looking for to...
|
by: Rabel |
last post by:
Hi I am a novice with both asp and javascript so I may not even be
doing this correctly, but I have an asp page that has variable being
passed to it and I have a button that I need to have it go to...
|
by: Twanne |
last post by:
I've got this query
Set rst4 = db.OpenRecordset("SELECT L,M,S FROM referenties WHERE type = '" & Form_PatChoise.ctype & "' AND geslacht = '" & Form_PatChoise.Sex & "' AND leeftijd = '" &...
|
by: StevoNZ |
last post by:
Hi,
I'm creating a query (queries more like) to build data for upload into a SAP system. For a given material I require a row of data defined, and for the same material another row with one field...
|
by: cdhaynes |
last post by:
Hi, I am using unbound text boxes in the header of a form to allow the user to search on a number of fields. I am using VBA to build a query string based on these and it has been fine when comparing...
|
by: rush2hem |
last post by:
I am trying to build a query which will give me unique rows. Details:-
Table 1 (F1, F2 are the columns)
F1 F2
1 A1
2 A2
3 A3
4 A4
Table 2 (F3,F4 are the columns)
F3 F4
|
by: kadishzm |
last post by:
Hi Everyone, I have recently been tasked with taking over a bunch of Access databases that I didn't create. My VBA skills are weak to say the best but I have a particular problem I am working on....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |