Having trouble using Order by when calling distinct
From: Ken (cyyu_tba_at_lycos.com)
Date: 09/23/04
- Next message: Jonathan Chong: "Re: master script to build database"
- Previous message: Jonathan Chong: "Re: Using output variables"
- Next in thread: John Bell: "RE: Having trouble using Order by when calling distinct"
- Reply: John Bell: "RE: Having trouble using Order by when calling distinct"
- Messages sorted by: [ date ] [ thread ]
Date: 22 Sep 2004 21:25:21 -0700
What I wanted to do here is to optimize performance by using
getstring. But I wanted same record to listed once and also listed in
order as well. But this code result in error, I think the problem is
to do with the item I use for order by doesnt get selected. I wonder
how I could fix this?
sSQL = "SELECT DISTINCT '<OPTION ' +"
sSQL = sSQL & "Case "
sSQL = sSQL & " WHEN PATINDEX('%,'+ CAST(PKID AS VARCHAR(10))+',%',
',"&trim(strGrp)&",')>0 THEN 'selected'"
sSQL = sSQL & " ELSE '' "
sSQL = sSQL & "END + ' value=' + CAST(PKID AS VARCHAR(10))+ '>' + "
sSQL = sSQL & "FabGroup +'</OPTION>' "
sSQL = sSQL & "FROM vw_opr_fab_gp as sk_main where 1=1 "
sSQL = sSQL + fseason&fYear&fBuyer
sSQL = sSQL & " ORDER BY FabGroup"
Set rsGrp = Server.CreateObject("ADODB.Recordset")
with rsGrp
.Open sSQL,Session.Contents("ADOConnection")
If .State > 0 then
If Not .EOF and Not .EOF Then
Response.Write .GetString(2, -1)
End If
.Close
End If
end with
Set rsGrp = Nothing
Ken
- Next message: Jonathan Chong: "Re: master script to build database"
- Previous message: Jonathan Chong: "Re: Using output variables"
- Next in thread: John Bell: "RE: Having trouble using Order by when calling distinct"
- Reply: John Bell: "RE: Having trouble using Order by when calling distinct"
- Messages sorted by: [ date ] [ thread ]