当前位置:网站首页>About SQL data query statements
About SQL data query statements
2022-07-24 16:01:00 【ZHZHK001】
1、 The foundation is not solid enough , The sentences used are the following results
<select id="relieveTotal" resultType="java.lang.Float">
SELECT SUM(SALES_AMOUNT) FROM TB_ORDER TR
WHERE TR.USER_ID = #{userId}
AND TR.SALES_TIME >= TO_DATE(TO_CHAR(
(SELECT MAX(W.WKH_MTIME)
FROM TB_WKH W
WHERE W.USER_ID = #{userId}
AND W.WKH_DIR = 0
GROUP BY W.USER_ID ) ,
'YYYY-MM-DD' ) , 'YYYY-MM-DD' )
</select>

How to add a column of data ( There is only one time value , It's part of the code above )
SELECT MAX(W.WKH_MTIME)
FROM TB_WKH W
WHERE W.USER_ID = 2
AND W.WKH_DIR = 0
GROUP BY W.USER_ID
Question 1 、
above 2 End code can get results , How to combine their results , Output ----- Become a row and two columns ( Decimal and time are in one column ) And the results of that come out ,
Who knows help
Question two 、
The previous code , Report errors :Cause: java.sql.SQLDataException: ORA-01861: Text does not match format string
What's the cause of the , Help me if you know , I don't know how to change it now :
At present, I can only adopt flexible methods ------ become resultMap Try your way
<select id="relieveTotal" resultMap="total_result"> <!-- Change the returned data type -->
SELECT SUM(SALES_AMOUNT) SALES_AMOUNT <!-- Use a field of the same type for temporary storage -->
FROM TB_ORDER TR
WHERE TR.USER_ID = #{userId}
AND TR.SALES_TIME >= TO_DATE(TO_CHAR(
(SELECT MAX(W.WKH_MTIME)
FROM TB_WKH W
WHERE W.USER_ID = #{userId}
AND W.WKH_DIR = 0
GROUP BY W.USER_ID ) ,
'YYYY-MM-DD' ) , 'YYYY-MM-DD' )
</select>
边栏推荐
- [tf.keras]: a problem encountered in upgrading the version from 1.x to 2.x: invalidargumenterror: cannot assign a device for operation embedding_
- Arduino IDE ESP32固件安装和升级教程
- Machine learning notes - building a recommendation system (5) feedforward neural network for collaborative filtering
- SQL row to column, column to row
- Dynamics crm: [problem solved]cannot open SQL encryption symmetric key because symmetric key password
- [leetcode] day103 search two-dimensional matrix II
- Leetcode 231. 2 的幂
- Kubernetes版本对接对象存储
- Kubernetes version docking object storage
- Is it safe for Anxin securities to open an account on mobile phone?
猜你喜欢

Machine learning notes - building a recommendation system (5) feedforward neural network for collaborative filtering

Will the capital market be optimistic about TCL's folding screen story?
![[shaders realize pixelate mosaic effect _shader effect Chapter 7]](/img/0f/3e8d9468d94b14217875c7e447aa15.png)
[shaders realize pixelate mosaic effect _shader effect Chapter 7]

JUC源码学习笔记3——AQS等待队列和CyclicBarrier,BlockingQueue

【SWT】自定义数据表格

iptables常用命令小清单

From which dimensions can we judge the quality of code? How to have the ability to write high-quality code?

105 constructing binary trees from preorder and inorder traversal sequences

LaneATT

Dynamics crm: how to set the order of forms
随机推荐
Nine key measures to maintain server security in Hong Kong
Varnish4.0 cache agent configuration
Choice of advanced anti DDoS IP and CDN in case of DDoS
Kubernetes GPU's Dilemma and failure
Some understanding of the rank sum of matrix and the rank of image
Dynamics crm: mailbox configuration (III) - configure email server profiles and mailboxes
[leetcode] day103 search two-dimensional matrix II
Knowledge points of MySQL (12)
[adaptiveavgpool3d] pytorch tutorial
How to choose the appropriate data type for fields in MySQL?
vscode常用快捷键
PHP中array_merge的坑
Is Huishang futures platform safe? Is it OK to open a futures account?
faster-rcnn 训练自己的数据集
Experience summary of slow SQL problems
【AdaptiveAvgPool3d】pytorch教程
Leetcode 223. rectangular area
Vscode common shortcut keys
Introduction to bermudagrass
Do you understand the working principle of gyroscope?