Reputation: 39
I have this following query
"select abc from table where val = 1"
The result i got was
[{abc=5}]
However, I need just the integer value 5 from the result instead of the array[{abc=5}].
Anyone have any idea on how to do this? thanks
*My friend told me that I will need to use substring to get just the 5 out from the [{abc=5}], but i have completely no clue on how to work on it. Any help will be appreciated!
*edited
Upvotes: 2
Views: 141
Reputation: 100
So, you need the exact value from the
[{abc=5}]
and you need to retrieve the value '5'? Am I right to say that?
Upvotes: 0
Reputation: 24116
try this:
Assume the integer value comes between = and } symbols
select substring(abc,charindex('=',abc)+1,len(abc)-charindex('}',abc))
Upvotes: 2
Reputation: 180
You need to use aggregate function count
select count(1) from table where val = 1
Use count(1) because it is optimized compare to count(*)
Upvotes: 0
Reputation: 1888
for the count of the column
select count(column) from table where val=1
Upvotes: 0