Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
coolbear91
Starting Member
2 Posts |
Posted - 2012-12-19 : 02:57:02
|
hi guys,I'm using some query to try to display the case below:table A has 100 rowsresult A = 100 rows, comes from table A with all [CP_LOAD%] valuesresult B = 25 rows, comes from table A which have [CP_LOAD%] > 100result C = 75 rows, comes from table A which have [CP_LOAD%] <= 100the query is as below:SELECT A.[Week] ,A.[DATE] ,A.[Time] ,A.[ACCLOAD] ,A.[NSCAN] ,A.[exchid] ,A.[CP_LOAD%]CP_LOAD FROM [BLADE_MJK29].[dbo].[dz_cpload] A WHERE( [Week] ,[DATE] ,[Time] ,[ACCLOAD] ,[NSCAN] ,[exchid] ,[CP_LOAD%]) NOT IN ( SELECT max([CP_LOAD%])CP_LOAD FROM [BLADE_MJK29].[dbo].[dz_cpload] group by [Week] ,[DATE] ,[Time] ) when I run it, it returns an error message like this:Msg 4145, Level 15, State 1, Line 12An expression of non-boolean type specified in a context where a condition is expected, near ','.what does it means?and how should I fix the script then? |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-12-19 : 03:12:27
|
[code]WHERE A.[CP_LOAD%] NOT IN ( SELECT max([CP_LOAD%]) CP_LOAD FROM [BLADE_MJK29].[dbo].[dz_cpload] group by [Week] ,[DATE] ,[Time] )[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-12-19 : 03:17:33
|
solution based on joinSELECT A.[Week] ,A.[DATE] ,A.[Time] ,A.[ACCLOAD] ,A.[NSCAN] ,A.[exchid] ,A.[CP_LOAD%] AS CP_LOAD FROM [BLADE_MJK29].[dbo].[dz_cpload] A LEFT JOIN ( SELECT [Week] ,[DATE] ,[Time] ,max([CP_LOAD%])CP_LOAD FROM [BLADE_MJK29].[dbo].[dz_cpload] group by [Week] ,[DATE] ,[Time] )t1 ON t1.[Week] = A.[Week]AND t1.[DATE] = A.[DATE]AND t1.[Time] = A.[Time]AND t1.CP_LOAD = A.[CP_LOAD%]WHERE t1.[Week] IS NULL ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|