当前位置:网站首页>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>
边栏推荐
- Hard core innovation that database needs to care about in the future
- Dynamics 365: how to get the authentication information required to connect to D365 online from azure
- SQL row to column, column to row
- 在LAMP架构中部署Zabbix监控系统及邮件报警机制
- Getting started with OpenMP
- 徽商期货平台安全吗?办理期货开户没问题吧?
- 【LOJ3247】「USACO 2020.1 Platinum」Non-Decreasing Subsequences(DP,分治)
- Deploy ZABBIX monitoring system and email alarm mechanism in lamp architecture
- Dynamics 365: how to get the threshold value of executemullerequest in batch requests
- Is Huishang futures platform safe? Is it OK to open a futures account?
猜你喜欢

简化理解:发布订阅
![[adaptiveavgpool3d] pytorch tutorial](/img/d0/60ee74ff554effa06084d5d01a03e1.png)
[adaptiveavgpool3d] pytorch tutorial

105 constructing binary trees from preorder and inorder traversal sequences

Dynamics crm: mailbox configuration (III) - configure email server profiles and mailboxes

Which is a good noise reduction Bluetooth headset? Ranking of the most cost-effective noise reduction Bluetooth headsets

矩阵的秩和图像的秩的一些了解

AttributeError: module ‘seaborn‘ has no attribute ‘histplot‘

有了这个机器学习画图神器,论文、博客都可以事半功倍了!

Using JS to implement click events

C# TCP客户端窗体应用程序异步接收方式
随机推荐
MySQL learning notes (summary)
YOLO5Face:为什么要重新发明人脸检测器
Configuring WAPI certificate security policy for Huawei wireless devices
105 constructing binary trees from preorder and inorder traversal sequences
Leetcode 223. 矩形面积
Leetcode 220. duplicate element III exists
聊聊C指针
降噪蓝牙耳机哪个好?性价比最高的降噪蓝牙耳机排行
20. Shell programming variables
Vscode common shortcut keys
torch_ How to use scatter. Scatter() in detail
应用修改日志路径log4j.properties
C# TCP客户端窗体应用程序异步接收方式
Getting started with OpenMP
[adaptiveavgpool3d] pytorch tutorial
2022 / 7 / 20 training record
Kubernetes static storage and dynamic storage
MySQL source code analysis -- data structure of index
2.19 haas506 2.0开发教程 - bluetooth - 蓝牙通信(仅支持2.2以上版本)
Hard core innovation that database needs to care about in the future