🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #4011

I Need help with a SQL sentence

#4011
From: Soldado de Fortuna
Date: Wed, 17 Apr 2002 21:02
122 lines
3580 bytes
Hello,

First of all I would like to know if this is the right
board where to post this request for help...

I'm not very good at SQL and I wonder if it's possible
to run a SQL which fetches the info that I want.

If this is not the right board  please let me know and

I will post it where you tell me to do it...

Otherwise, please read on...  ;-)


------------------------------------------------------


I'm building a "tests application" based on VB and an
access DB.

The users enter their guesses which are stored in the
DB...

Once all the users have entered their answers I'd like
to show a ranking of the users ordered by the number
of
right answers...

If it's possible with just one SQL (it may have nested
SQLs),
if not... a couple of related Recordsets may do...



Right now I run a SQL, from this initial Recordset I
calculate
the points for each user in the VB program... then
store
this info in an extra field (Points) in the DB...

...finally I run a second SQL with an "order by
Points".

As I find this solution too messy I ask for help...

Any suggestion will be welcome.



If you feel that my theory is feasable, here you are
detailed
info about what I got...



The DB description:

Table1
--------------------    Possible values
Name Text
FieldA Text (A1,A2,A3,A4)
FieldB Text (B1,B2,B3,B4)
FieldC Text (C1,C2,C3,C4)
FieldD Text (D1,D2,D3,D4)
FieldE Text (E1,E2,E3,E4)
FieldF Text (F1,F2,F3,F4)
FieldG Text (G1,G2,G3,G4)
FieldH Text (H1,H2,H3,H4)



Example of possible data in the DB:


Name FieldA FieldB FieldC FieldD

1    A1     B3     C4     D2
2    A3     B1     C1     D4
3    A1     B1     C2     D3
4    A2     B2     C4     D2
5    A3     B1     C3     D3
6    A4     B3     C2     D4
.    .      .      .      .
.    .      .      .      .
.    .      .      .      .



Let's say the correct answers are:

     A3     B1     C1     D4


and that we give 1 point for every right answer...

Based on these correct answers the SQL should fetch
the
records ordered by the points gained:


Name FieldA FieldB FieldC FieldD "POINTS"

2    A3     B1     C1     D4     8
5    A3     B1     C3     D3     5
1    A1     B3     C4     D2     2
3    A1     B1     C2     D3     2
6    A4     B3     C2     D4     2
4    A2     B2     C4     D2     1
.    .      .      .      .      .
.    .      .      .      .      .
.    .      .      .      .      .
.    .      .      .      .      .

Please reply to
Ramon.Martinez-Cazon@ree.ericsson.se

Thank you for your attention.

Kind regards.

RAMON
Technical Details
Message-ID: <a9knts$429hk$1@ID-130167.news.dfncis.de>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!sc1-1a-u-0117.mc.onolab.COM!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,533395238507919f,start
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-04-17 14:03:01 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!sc1-1a-u-0117.mc.onolab.COM!not-for-mail
From: "Soldado de Fortuna" <e_laro@hotmail.com>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: I Need help with a SQL sentence
Date: Wed, 17 Apr 2002 23:02:22 +0200
Lines: 132
Message-ID: <a9knts$429hk$1@ID-130167.news.dfncis.de>
NNTP-Posting-Host: sc1-1a-u-0117.mc.onolab.com (62.42.144.118)
X-Trace: fu-berlin.de 1019077372 4269620 62.42.144.118 (16 [130167])
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000