字符串而不是sql查询结果

编程入门 行业动态 更新时间:2024-10-26 14:34:55
本文介绍了字符串而不是sql查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

朋友,我想执行查询以获取2个日期之间的日期.但是我的问题是我需要一个通用字符串而不是结果值 对于EG:查询结果:12-05-1658 我需要"h"而不是12-05-1658 编辑 ---------------------------- 此查询仅返回日期.我需要查找相应日期的状态

Hi Friends I want to execute a query for getting the date between 2 dates..But my problem is i need a common string instead of the result-value For EG: The query result:12-05-1658 I need ''h'' instead of 12-05-1658 EDIT ---------------------------- This query returns only date.I need to find the status of corresponding dates

select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='H' or Status='A' ) except select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='A'or Status='FL' or Status='H' ) intersect ( (select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='H' or Status='A' ) except select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='H' ) ) union (select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='H' or Status='A' ) except select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='A' or Status='H' ) ) union (select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='H' or Status='A' ) except select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='A' ) ) ) union (select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='H' or Status='A' ) except select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='H' ) ) union (select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='H' or Status='A' ) except select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='A' or Status='H' ) ) union (select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='H' or Status='A' ) except select distinct date from tblStdntAttndnce where Batch_Id='233' and MONTH(date)='6' and YEAR(date)='2011' and (Status='P'or Status='FL' or Status='A' ) ) order by DATE

推荐答案

为什么要这样? 好吧,您可以使用案例 [ ^ ]语句(如果结果行较少),但如果结果行较多,则需要使用存储过程(带有CASE语句). Why do you want like that? Well, you can use CASE[^] statement for that(If result rows are less) but If result rows are more then you need use stored procedure(with CASE statement).

更多推荐

字符串而不是sql查询结果

本文发布于:2023-06-13 04:31:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/674158.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   查询结果   而不是   sql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!