Saturday, February 25, 2012

CrossTable - SQL Server 2000 Help me

Hello,

sorry for my English.. i have this problem

two tables

TABLE_A

Import

65

132

244

165

TABLE_B

FromValue ToValue

0 100

101 200

201 1000

i'd like a query that have to result this

Field1 Field2 Field3 (Count of table A)

0 100 1

101 200 2

201 1000 1

and if i change the table B this query automatically change..

thank's very much

Try

SELECT FromValue ToValue,
(SELECT COUNT(*) FROM TableA A WHERE A.ImportBETWEEN B.FromValue AND B.ToValue) AS Cnt
FROM TableB

|||Thank's very much

No comments:

Post a Comment