我正在使用Crystal Report v8.5来显示仍有余额的客户列表。
下面是我写的SQL表达式
SELECT
"c"."firstname","c"."lastname"
"transaction"."record", "transaction"."balsheet"
FROM
"dbproj"."dbo"."c" "c"
"dbproj"."dbo"."transaction" "transaction"
INNER JOIN
"dbproj"."dbo"."c" "c" ON "c"."clientid"="transaction"."clientid"
WHERE
("transaction"."tstatus"='UNPAID')
ORDER BY
"c"."lastname"
我是Crystal Reports的新手,所以我对如何将SQL语句转换为SQL表达式进行了彻底的研究,这就是我所得到的。但是当我把它放在SQL表达式上时,消息框表明使用的表达式存在错误。
还有什么我还需要改进吗?或者我将此查询放在SQL表达式字段上的事实是一个可怕的想法?我在youtube频道上看到了一个演示,所以我(以某种方式)确信我所做的是对的,但如果是这样,为什么我会收到此错误消息?
答案 0 :(得分:4)
我很想看到给你这种语法的youtube视频,因为它错了 - 你要么错误地转录它,要么发布者应该取走他们的SQL许可证。
SELECT c.firstname, c.lastname, t.record, t.balsheet
------ missing comma here ----^
FROM
----- extra reference to the table "c" removed here
dbproj.dbo.[transaction] AS t -- used an alias here too, just like c below
INNER JOIN dbproj.dbo.c AS c
ON c.clientid = t.clientid
WHERE t.tstatus = 'UNPAID'
ORDER BY c.lastname;
答案 1 :(得分:0)
您的FROM
条款应该只是:
FROM
"dbproj"."dbo"."transaction" "transaction"
完整查询:
SELECT
"c"."firstname","c"."lastname",
"transaction"."record", "transaction"."balsheet"
FROM
"dbproj"."dbo"."transaction" "transaction"
INNER JOIN
"dbproj"."dbo"."c" "c" ON
"c"."clientid"="transaction"."clientid"
WHERE
("transaction"."tstatus"='UNPAID')
ORDER BY
"c"."lastname"