Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Case in sql statement

$
0
0

I have this query 

select count ( * )
from 
table1
where 
code ='947'
and update_date >='2019-01-01' and update <= '2019-01-31'
and
case when left(st_no,2)='US' then left (st_no,9) else com_code end='US0010101'
group by bng_date

now in that case condition 

case when left(st_no,2)='US' then left (st_no,9) else com_code end='US0010101'

this query fetch data of this 'US0010101' against this condition

left(st_no,2)='US'then left (st_no,9)


and data display like per day wise 

now i want data  of all com_code wise against this condition

 left(st_no,2)='US' then left (st_no,9)


how i modify this query ?

if case is not work then any other alternative solution ?





Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>