0

Access 2003 中的输出:

身份证 | 说明 | 数量 | 标题 | 对象
--------------------------------------------------------------- --------------------

17 | 6 | 253000.00 | |
18 | 7 | 330000.00 | |
19 | 1 | 340000.00 | 8414 | 69327
22 | 2 | 120000.00 | 8414 | 69344
23 | 3 | 615000.00 | 8414 | 69327
24 | 4 | 320000.00 | 8414 | 69327
25 | 5 | 809500.00 | 8414 | 69327

询问 :

SELECT      TVFundBillDetail.ID ,
            TVFundBillDetail.HID ,
            TVFundBillDetail.Description ,
            TVFundBillDetail.Quantity ,
            TVFundBillDetail.Title ,
            TVTitle.Name TitleName ,
            Obj ,
            TVAllObjects.Name ObjName
     FROM   TVFundBillDetail
            LEFT OUTER JOIN TVTitle ON TVFundBillDetail.Title = TVTitle.Code
            LEFT OUTER JOIN TVAllObjects ON TVFundBillDetail.Obj = TVAllObjects.Code

问题:输入行序列显示在描述列中。当 title 和 obj 为 null 时,则替换输入行的序列。应用程序是 access 2003 而 DBMS 是 SQL Server 2000

4

1 回答 1

0

There are probably many ways to achieve this. For Access, you can simply use Nz() in your query, like this:

...
Nz(TVFundBillDetail.Title, "    ")
...

If Title is NULL, you'll get 4 spaces (or you can use "0000" if you prefer).

For SQL server, an equivalent function is COALESCE():

...
COALESCE(TVFundBillDetail.Title, "    ")
...

If you're using the query as a normal Qccess query, the first one will work. If you're using a pass-through query, or exposing a SQL Server view, the second one will work.

于 2012-11-11T07:24:54.887 回答