473,394 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Sorting four columns using sql query in query analyzer

49
Hi to all

I have one table with 6 columns and 20 rows.I want to sort each and every column when i click the column name in the table.

for sorting i create one more page.when i click the column name it connect to sorting page and then page will be sorting. like this i wnat to write the code.
i wrote some code,but it not working properly.my code is

For first page:

<%userdetails=session("userdetails")
userpoint=instr(1,userdetails,",")
'mt=mid(userdetails,1,userpoint-1)
sort_var=request.querystring("valb4")

%>

<td bgcolor="black" nowrap><b><a href="hco_Qc_Status1_sort123.asp?valb4=#_id" ><b><font color="white" style="text-decoration:none">&nbsp;#</b></font></td>
<td bgcolor="black" nowrap><b><a href="hco_Qc_Status1_sort123.asp?valb4=id_id" ><b><font color="white" style="text-decoration:none">&nbsp;ID</b></font></td>
<td bgcolor="black" nowrap><b><a href="hco_Qc_Status1_sort123.asp?valb4=name" ><b><font color="white" style="text-decoration:none">&nbsp;Name</b></font></td>
<td bgcolor="black" nowrap><b><a href="hco_Qc_Status1_sort123.asp?valb4=team_name1" ><b><font color="white" style="text-decoration:none">&nbsp;Team</b></font></td>
<td bgcolor="black" nowrap><b><a href="hco_Qc_Status1_sort123.asp?valb4=Acc_no" ><b><font color="white" style="text-decoration:none">&nbsp;ACC</b></font></td>
<td bgcolor="black" nowrap><b><a href="hco_Qc_Status1_sort123.asp?valb4=job_no" ><b><font color="white" style="text-decoration:none">&nbsp;Job</b></font></td>
<td bgcolor="black" nowrap><b><a href="hco_Qc_Status1_sort123.asp?valb4=qc_id" ><b><font color="white" style="text-decoration:none">&nbsp;Status</b></font></td>
<td bgcolor="black" nowrap><b><a href="hco_Qc_Status1_sort123.asp?valb4=type_name" ><b><font color="white" style="text-decoration:none">&nbsp;Type</b></font></td>

<!--<td><b><font face="Verdana" size="2">&nbsp;Remarks</font></b></td>-->
<td bgcolor="black" nowrap><b><a href="hco_Qc_Status1_sort123.asp?valb4=error_name" ><b><font color="white" style="text-decoration:none">&nbsp;Error</b></font></td>

---

if sort_var="qc_id" then

''sqlqr="Select client_id,editor_id,qc_id,job_no,tc_time,qc_date,d ictator_name1,dictation_length,wt from tws_stats where qc_date='"&date&"'and job_no <> '' order by "& sort_var &" desc"
' sqlqr="Select id_id,team_name1,Acc_no,job_no,type_name,error_nam e,name from tws_stats where qc_date='"&date&"'and job_no <> '' order by "& sort_var &" desc"
sqlqr="select Id,name from tws_stats where qc_date='"&date&"' ORDER BY name DESC "
'sqlqr="Select name from tws_stats order by sort_var"
' Response.Write sqlqr

else
'sqlqr="Select client_id,editor_id,qc_id,job_no,tc_time,qc_date,d ictator_name1,dictation_length,wt from tws_stats where qc_date='"&date&"'and job_no <> '' order by "& sort_var &" asc"

'sqlqr="Select id_id,team_name1,Acc_no,job_no,type_name,error_nam e,name from tws_stats where qc_date='"&date&"'and job_no <> '' order by "& sort_var &" asc"
sqlqr="select Id,name from tws_stats where qc_date='"&date&"' ORDER BY name ASC "



And for sorting page code is :


%userdetails=session("userdetails")
userpoint=instr(1,userdetails,",")
'mt=mid(userdetails,1,userpoint-1)
sort_var=request.querystring("valb4")
%>

<td align="middle" bgcolor="black" nowrap><A href="Copy of Grades-Unacceptable.asp?valb4=#_id"><b><font color="white" style="TEXT-DECORATION: none">#</b></font></a></td>
<td align="middle" bgcolor="black" nowrap><font color="white"><A href="Copy of Grades-Unacceptable.asp?valb4=ID_id"><font color="white" style="TEXT-DECORATION: none"><b>ID</b></font></a></font></td>
<td align="middle" bgcolor="black" nowrap><font color="white"><A href="Copy of Grades-Unacceptable.asp?valb4=name"><font color="white" style="TEXT-DECORATION: none"><b>Name</b></font></a></font></td>
<td align="middle" bgcolor="black" nowrap><font color="white"><A href="Copy of Grades-Unacceptable.asp?valb4=team_name1"><b><font color="white" style="TEXT-DECORATION: none">Team</b></font></A></font></td>
<td align="middle" bgcolor="black" nowrap><font color="white"><A href="Copy of Grades-Unacceptable.asp?valb4=Acc_no"><font color="white" style="TEXT-DECORATION: none"><b>ACC</b></font></a></font></td>
<td align="middle" bgcolor="black" nowrap><font color="white"><A href="Copy of Grades-Unacceptable.asp?valb4=job_no"><font color="white" style="TEXT-DECORATION: none"><b>Job</b></font></a></font></td>
<td align="middle" bgcolor="black" nowrap><font color="white"><A href="Copy of Grades-Unacceptable.asp?valb4=qc_id"><font color="white" style="TEXT-DECORATION: none"><b>Status</b></font></a></font></td>
<td align="middle" bgcolor="black" nowrap><font color="white"><A href="Copy of Grades-Unacceptable.asp?valb4=type_name"><font color="white" style="TEXT-DECORATION: none"><b>Type</b></font></a></font></td>
<td align="middle" bgcolor="black" nowrap><font color="white"><A href="Copy of Grades-Unacceptable.asp?valb4=error_name"><font color="white" style="TEXT-DECORATION: none"><b>Error</b></font></a></font></td>


<%
if sort_var="qc_id" then
'sqlqr="Select client_id,editor_id,qc_id,job_no,tc_time,qc_date,d ictator_name1,dictation_length,wt from tws_stats where qc_date='"&date&"'and job_no <> '' order by "& sort_var &" desc"
' sqlqr="Select id_id,team_name1,Acc_no,job_no,type_name,error_nam e,name from tws_stats where qc_date='"&date&"'and job_no <> '' order by "& sort_var &" desc"
'ex table name = infos_today
sqlqr="select Id,name from infos_today where qc_date='"&date&"' ORDER BY name DESC "

'Response.Write sqlqr
else
'sqlqr="Select client_id,editor_id,qc_id,job_no,tc_time,qc_date,d ictator_name1,dictation_length,wt from tws_stats where qc_date='"&date&"'and job_no <> '' order by "& sort_var &" asc"
'sqlqr="Select id_id,team_name1,Acc_no,job_no,type_name,error_nam e,name from tws_stats where qc_date='"&date&"'and job_no <> '' order by "& sort_var &" asc"
sqlqr="select Id,name from infos_today where qc_date='"&date&"' ORDER BY name ASC "

'Response.Write sqlqr
end if
dim rs
'set rsIn =myconn.execute(sqlqr)
set rs=myconn.execute(sqlqr)
if not(rs.eof and rs.bof) then
get1=rs.getrows
set rs=nothing
get2=ubound(get1,2)
for i=0 to get2
%>



please check the above code.

please tell me the sql query for sorting 5 columns in a table.
Sep 1 '08 #1
3 1637
code green
1,726 Expert 1GB
please check the above code
No thanks. This looks like a VB problem not SQL server
Sep 1 '08 #2
nagmvs
49
No thanks. This looks like a VB problem not SQL server
Hello sir,

Thanks for ur reply.Sir actually i want the sql query for sorting 5 columns in a table using query analyzer.If u know means please tell me.

thanks,
nagesh.
Sep 2 '08 #3
code green
1,726 Expert 1GB
i want the sql query for sorting 5 columns in a table using query analyzer.
Are you asking how to use the ORDER BY clause?
Expand|Select|Wrap|Line Numbers
  1. ORDER BY col1,col2,col3.....
Sep 2 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Taylor | last post by:
I have a ListCtrl with 5 columns. The first 4 columns are either strings or integers, but the last column is a string in the format of MM-DD-YYYY. I searched google and also read over the...
4
by: Rich Hurley | last post by:
We've just installed SQL Server 2000 on one of our servers and have noticed a strange behavior. When clicking the column headings in the job display in Enterprise Manager, the list is sorted (first...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
19
by: matt | last post by:
I've seen several posts that begin to address this problem, but have not found a simple, elegant solution that will accomplish this goal. The important part of this solution is that it must be...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
1
by: anupam roy | last post by:
Hi All, I have a coloumn collection which consists of four columns(A,B,C,D). Now i want to sort this collection based on two particular columns(A,B) one a a time.The two columns may very well...
6
by: stocki | last post by:
Hi, On my WinForm I have a DataGridView, which contains four columns and four rows. The last row contains only a sum of the values of the cells of the previous rows in column 3. The cells , , ...
3
by: =?Utf-8?B?U2NvdHQ=?= | last post by:
Good afternoon, I would like to mimic the sorting capabilities in Excel where I can sort a list by up to four properties (columns in excel). I would like to pass a collection of objects to a...
1
by: dorandoran | last post by:
The sort on the childgrid is not working; nothing happens when I click on the each column header for sort. (I followed Satay's sample: http://www.codeproject.com/KB/aspnet/EditNestedGridView.aspx)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.