PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → order by list in query not work
order by list in query not work
Iniciado por guest, 15,abr. 2015 07:18 - 14 respuestas
Publicado el 15,abril 2015 - 07:18
i am try to this query but not work


SELECT
QuestionMaster.QuestionMasterID AS QuestionMasterID,
QuestionMaster.QM_SM_Id AS QM_SM_Id,
QuestionMaster.QM_CM_ID AS QM_CM_ID,
QuestionMaster.QM_DetailQuestion AS QM_DetailQuestion,
QuestionMaster.QM_Name AS QM_Name,
QuestionMaster.QM_AnsA AS QM_AnsA,
QuestionMaster.QM_AnsB AS QM_AnsB,
QuestionMaster.QM_AnsC AS QM_AnsC,
QuestionMaster.QM_AnsD AS QM_AnsD,
QuestionMaster.QM_CurrectAns AS QM_CurrectAns,
QuestionMaster.QM_Remark AS QM_Remark,
ChapterMaster.ChapterMasterID AS ChapterMasterID,
ChapterMaster.CM_SM_ID AS CM_SM_ID,
ChapterMaster.CM_Name AS CM_Name,
ChapterMaster.CM_Mark AS CM_Mark,
Random AS Rs
FROM
QuestionMaster
LEFT JOIN ChapterMaster ON
ChapterMaster.ChapterMasterID=QuestionMaster.QM_CM_ID
ORDER BY
ra ASC
LIMIT ChapterMaster.CM_Mark AS CM_Mark
Publicado el 15,abril 2015 - 15:28
Hi Vijay,

What is the "ra" field? Usually you must specify the table name to. Like "ChapterMaster.ra".

Best regards,
Alexandre Leclerc
Publicado el 15,abril 2015 - 18:21
hello,

rs is random data select field ,
but i am get output a random record selecte

rs is random and how many record get is specify for LIMIT ChapterMaster.CM_Mark AS CM_Mark.
that is not worked..


but this code is work successfully give belove:-
SELECT
QuestionMaster.QuestionMasterID AS QuestionMasterID,
QuestionMaster.QM_SM_Id AS QM_SM_Id,
QuestionMaster.QM_CM_ID AS QM_CM_ID,
QuestionMaster.QM_DetailQuestion AS QM_DetailQuestion,
QuestionMaster.QM_Name AS QM_Name,
QuestionMaster.QM_AnsA AS QM_AnsA,
QuestionMaster.QM_AnsB AS QM_AnsB,
QuestionMaster.QM_AnsC AS QM_AnsC,
QuestionMaster.QM_AnsD AS QM_AnsD,
QuestionMaster.QM_CurrectAns AS QM_CurrectAns,
QuestionMaster.QM_Remark AS QM_Remark,
ChapterMaster.ChapterMasterID AS ChapterMasterID,
ChapterMaster.CM_SM_ID AS CM_SM_ID,
ChapterMaster.CM_Name AS CM_Name,
ChapterMaster.CM_Mark AS CM_Mark,
Random AS Rs
FROM
QuestionMaster
LEFT JOIN ChapterMaster ON
ChapterMaster.ChapterMasterID=QuestionMaster.QM_CM_ID
ORDER BY
ra ASC
LIMIT 50
Publicado el 15,abril 2015 - 18:30
what is the error? not the expected results, wx error?

Why Random AS Rs and ORDER BY ra ASC, if you use rs in the select you must use rs in the order not ra

Did you check all the answers in all the other post you have opened regarding this isue?
Publicado el 16,abril 2015 - 13:44
i am try to this code but give error


SELECT
QuestionMaster.QuestionMasterID AS QuestionMasterID,
QuestionMaster.QM_SM_Id AS QM_SM_Id,
QuestionMaster.QM_CM_ID AS QM_CM_ID,
QuestionMaster.QM_DetailQuestion AS QM_DetailQuestion,
QuestionMaster.QM_Name AS QM_Name,
QuestionMaster.QM_AnsA AS QM_AnsA,
QuestionMaster.QM_AnsB AS QM_AnsB,
QuestionMaster.QM_AnsC AS QM_AnsC,
QuestionMaster.QM_AnsD AS QM_AnsD,
QuestionMaster.QM_CurrectAns AS QM_CurrectAns,
QuestionMaster.QM_Remark AS QM_Remark,
ChapterMaster.ChapterMasterID AS ChapterMasterID,
ChapterMaster.CM_SM_ID AS CM_SM_ID,
ChapterMaster.CM_Name AS CM_Name,
ChapterMaster.CM_Mark AS CM_Mark,
RANDOM( ) AS ra
FROM
QuestionMaster
LEFT OUTER JOIN
ChapterMaster
ON ChapterMaster.ChapterMasterID = QuestionMaster.QM_CM_ID
WHERE
(
ChapterMaster.ChapterMasterID = {param1}
)
ORDER BY
ra ASC
LIMIT {param2}
Publicado el 16,abril 2015 - 14:09
Hi Vijay,

Help us helping you: what is the error? Please post the whole error message.

Kind regards,
Alexandre Leclerc
Publicado el 16,abril 2015 - 15:38
Are you using version 20?
Publicado el 16,abril 2015 - 19:24
no..
over software version is windev17

but version in not generatred not above over write query..sir,

error is

ORDER BY
ra ASC
LIMIT {param2}

this code
Publicado el 16,abril 2015 - 20:03
Hi Vijay,

If you are not using version 20 you cannot use a parameter to control the LIMIT clause. The solution left for you in this case is to build the query yourself in a string with the desired parameters then execute the query with HExecuteSQLQuery().

(Also, when someone asks for the error message, providing the line of code throwing the error is useful, but the actual displayed error message, like "invalid parameter on LIMIT ...", is way more useful for others to help you.)

Best regards,
Alexandre Leclerc
Publicado el 16,abril 2015 - 20:13
Maybe an extra SELECT will work?

SELECT * FROM
(SELECT
QuestionMaster.QuestionMasterID AS QuestionMasterID,
QuestionMaster.QM_SM_Id AS QM_SM_Id,
QuestionMaster.QM_CM_ID AS QM_CM_ID,
QuestionMaster.QM_DetailQuestion AS QM_DetailQuestion,
QuestionMaster.QM_Name AS QM_Name,
QuestionMaster.QM_AnsA AS QM_AnsA,
QuestionMaster.QM_AnsB AS QM_AnsB,
QuestionMaster.QM_AnsC AS QM_AnsC,
QuestionMaster.QM_AnsD AS QM_AnsD,
QuestionMaster.QM_CurrectAns AS QM_CurrectAns,
QuestionMaster.QM_Remark AS QM_Remark,
ChapterMaster.ChapterMasterID AS ChapterMasterID,
ChapterMaster.CM_SM_ID AS CM_SM_ID,
ChapterMaster.CM_Name AS CM_Name,
ChapterMaster.CM_Mark AS CM_Mark,
Random AS Rs
FROM
QuestionMaster
LEFT JOIN ChapterMaster ON
ChapterMaster.ChapterMasterID=QuestionMaster.QM_CM_ID
)
ORDER BY Rs ASC
LIMIT 1,10
Publicado el 17,abril 2015 - 14:48
i am use this code
--------------------------
QRY_SubjectWaysChapterList.Param1=1
HExecuteQuery(QRY_SubjectWaysChapterList)
HReadFirst(QRY_SubjectWaysChapterList)
sMyQry is string = "select * from QuestionMaster where qm_cm_id=1 order by RAND() limit "+QRY_SubjectWaysChapterList.CM_Mark
CustomerQry is Data Source

HExecuteSQLQuery(CustomerQry,sMyQry)
Info(HNbRec(CustomerQry))
-------------------------------
but give belowe error
-------------------------

Error at line 10 of Click BTN_NoName4 process.
HNbRec function called.
file unknown in analysis, or query or view not initialized.
If it is a query, the execution of this query may have failed.

----- Technical Information -----

Project : EXAM SYSTEM

WL call:
Process of 'Click BTN_NoName4' (WIN_TestDetails.BTN_NoName4), line 10, thread 0
'HNbRec' function, syntax 1

What happened?
file unknown in analysis, or query or view not initialized.
If it is a query, the execution of this query may have failed.

Error code: 70018
Level: fatal error (EL_FATAL)
WD55 error code: 18

Dump of the error of 'WD170HF.DLL' module (17.0.161.3).
Identifier of detailed information (.err): 70116
Debugging information:
IEWDHF=1.1
Module=
Version=<17.0.161.3>
Fonction (7,58)
Additional Information:
EIT_PATHWDD :
EIT_LOGICALTABLENAME :
EIT_PILEWL :
Click BTN_NoName4 (WIN_TestDetails.BTN_NoName4), line 10
EIT_DATEHEURE : 17/04/2015 05:43:57

Help

- Check that the file is described in the current analysis.
- For a dynamically described file, check that it has been properly
declared with HDeclare, HDeclareExternal or HDescribeFile.
- For a query created in the query editor, or a query written in
SQL language, check that it has been declared with HExecuteQuery
or HExecuteSQLQuery.
Publicado el 17,abril 2015 - 15:39
Hi,

The error you are presenting is the error you get when you access a data source from a query that failed to execute.
You need to check the error description right after executing the query.
Either by:
setting a breakpoint right after hexecutequery and check the herrorinfo line in the debugger
or
by programming: if not hexecutequery() then Error(herrorinfo(fulldetails))

Regards,
Piet
Publicado el 17,abril 2015 - 15:41
instead of Info(HNbRec(CustomerQry)) use info(ErrorInfo(errFullDetails)) and post the result here.
Publicado el 17,abril 2015 - 16:08
As far as i can see RAND() isn't suported by HFSQL, but you should know that, DerekT told you in your previous post in january regarding the same problem
http://27130.foren.mysnip.de/read.php…

check the help please:
<a class="ExternalLink" rel="nofollow" target="_blank" href="http://doc.windev.com/en-US/?2034002&name=Mathematical_SQL_functions">http://doc.windev.com/en-US/&hellip;</a>
Publicado el 17,abril 2015 - 18:54
thank you,

all of Sir,

my problem is solied.

thank you,
thank you,sir