|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Query returning wrong dataim running this query as i need to have an index number for a vb.net datset
"Select t1.*, (select count(*) from BossData.dbo.OriginatingAccounts t3 where t3.tblOA_Licence < t1.tblOA_Licence) as IdCol from BossData.dbo.OriginatingAccounts as t1 Where t1.tbloa_licence = 'TEST' Order By t1.tblOA_Licence, t1.tblOA_AccountID" there are 16 records that have a licence number of 'TEST' and they start at position 260 in the table ( when applied in licence order ) , when this query return i need it the IdCol to start at 0 - 15 NOT 260 - 275 In your outer SELECT statemenet your WHERE clause has a filter (Where
t1.tbloa_licence = 'TEST' ). You need to repeat the same filter in your inner SELECT as well. "Peter Newman" <PeterNew***@discussions.microsoft.com> wrote in message im running this query as i need to have an index number for a vb.net datsetnews:9F17BF1B-0E71-48C1-BC70-78D1E8D00B52@microsoft.com... "Select t1.*, (select count(*) from BossData.dbo.OriginatingAccounts t3 where t3.tblOA_Licence < t1.tblOA_Licence) as IdCol from BossData.dbo.OriginatingAccounts as t1 Where t1.tbloa_licence = 'TEST' Order By t1.tblOA_Licence, t1.tblOA_AccountID" there are 16 records that have a licence number of 'TEST' and they start at position 260 in the table ( when applied in licence order ) , when this query return i need it the IdCol to start at 0 - 15 NOT 260 - 275 Narayana,
Thank you for the input , however all i can get out is 16 records all witht he same idcol = 16 Show quote "Narayana Vyas Kondreddi" wrote: > In your outer SELECT statemenet your WHERE clause has a filter (Where > t1.tbloa_licence = 'TEST' ). > > You need to repeat the same filter in your inner SELECT as well. > -- > HTH, > Vyas, MVP (SQL Server) > SQL Server Articles and Code Samples @ http://vyaskn.tripod.com/ > > > "Peter Newman" <PeterNew***@discussions.microsoft.com> wrote in message > news:9F17BF1B-0E71-48C1-BC70-78D1E8D00B52@microsoft.com... > im running this query as i need to have an index number for a vb.net datset > > "Select t1.*, (select count(*) from BossData.dbo.OriginatingAccounts t3 > where t3.tblOA_Licence < t1.tblOA_Licence) as IdCol from > BossData.dbo.OriginatingAccounts as t1 Where t1.tbloa_licence = 'TEST' > Order > By t1.tblOA_Licence, t1.tblOA_AccountID" > > there are 16 records that have a licence number of 'TEST' and they start at > position 260 in the table ( when applied in licence order ) , when this > query return i need it the IdCol to start at 0 - 15 NOT 260 - 275 > > > |
|||||||||||||||||||||||