简体   繁体   English

将列值设置为子查询结果

[英]Set a column value to a subquery result

not sure if my search is wrong or what but I'm turning up no results , Basically I have the following sql query 不知道我的搜索是错误的还是什么,但是我没有结果,基本上我有以下sql查询

SELECT DISTINCT ClientID, EventType, EventDescription,EventTime AS
                      (SELECT     SUBSTRING(EventTime, 0, 12))
 FROM         EventLog
 WHERE     (EventType = 'Gig')

I want to have it so that the column EventTime is a substring of the actual value 我想要它,以便EventTime列是实际值的子字符串

Could someone show me how to do this as the above query won't execute, apologies if this is an obvious question 有人可以告诉我如何执行此操作,因为上面的查询将不会执行,如果这是一个明显的问题,我深表歉意

Try this way: 尝试这种方式:

SELECT DISTINCT ClientID, EventType, EventDescription,
                SUBSTRING(EventTime, 0, 12) as EventTime                           
FROM         EventLog
WHERE     (EventType = 'Gig')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM