我的查询语句是这样的
- SQL code
select distinct customer_code from purchase_customer_balance order by customer_code
我想在查询结果中添加字符串,如下
- SQL code
select distinct '@'+customer_code'#' from purchase_customer_balance order by customer_code
但执行错误,提示如下:
如果指定了 SELECT DISTINCT,那么 ORDER BY 子句中的项就必须出现在选择列表中。
怎样解决这个问题?
另外如果我想添加的字符串不是 @ 而是 ' 怎样解决?
------解决方案--------------------
- SQL code
select distinct '@'+customer_code+'#' from purchase_customer_balance order by customer_code
------解决方案--------------------
- SQL code
select distinct '@'+customer_code + '#' from purchase_customer_balance order by 1or :select distinct '@'+customer_code + '#' from purchase_customer_balance order by '@'+customer_code + '#'
------解决方案--------------------
- SQL code
SELECT DISTINCT '@' + customer_code + '#'FROM purchase_customer_balanceORDER BY '@' + customer_code + '#'
------解决方案--------------------
select distinct '@'+customer_code'#' from purchase_customer_balance order by '@'+customer_code'#'