更新时间:2022-11-14 18:28:20
选择非重复计数(UserId)
来自 RawData
其中 ' 06 / Nov /之间的TimeEntry 2014 09:00:00 AM'
和' 06 / Nov / 2014 10:00 :00 AM') as ' BreakFast '
来自 RawData as rd
inner 加入 StaffMas ter as sm
on rd.UserID = sm.UserIdN
试试这个:选择 * from( select distinct rd.UserID,sm.EmpNameC from RawData as rd inner join StaffMaster as sm on rd.UserID = sm.UserIdN)t1 inner join
(选择 count(UserId),userId 来自 RawData 其中 TimeEntry ' 06 / Nov / 2014 09:00:00 AM' 和 ' 06 / Nov / 2014 10:00:00 AM' group by userId)t2 on t1.userId = t2.userId
语法为:选择 * from( select userId,name from table1) t1 内部 join ( select count(userid ),名称来自 table2)t2 on t1.userId = t2.userId
hi All
Here i have problem with this query i want total number of columns,
My Query:
select distinct rd.UserID,sm.EmpNameC,(select count(UserId) from RawData where TimeEntry between '06/Nov/2014 09:00:00 AM' and '06/Nov/2014 10:00:00 AM') as 'BreakFast' from RawData as rd inner join StaffMaster as sm on rd.UserID=sm.UserIdN
Output Like:
BreakFast
0
0
0
0
like this i want total sum of this column, what to do....
select distinct count(UserId) from RawData where TimeEntry between '06/Nov/2014 09:00:00 AM' and '06/Nov/2014 10:00:00 AM') as 'BreakFast' from RawData as rd inner join StaffMaster as sm on rd.UserID=sm.UserIdN
try this:select *from ( select distinct rd.UserID,sm.EmpNameC from RawData as rd inner join StaffMaster as sm on rd.UserID=sm.UserIdN) t1 inner join (select count(UserId),userId from RawData where TimeEntry between '06/Nov/2014 09:00:00 AM' and '06/Nov/2014 10:00:00 AM' group by userId) t2 on t1.userId=t2.userId
The Syntax is :select *from (select userId,name from table1)t1 inner join (select count(userid),name from table2)t2 on t1.userId=t2.userId