Skip to content

MySql search integer range from number with dash

I have table in that I have one field with dash value. Like… I need to search this with between condition. For example if I have one value 25 then I need to search the records which include the value 25 like 20-31. In above image there are 6 records which include 25 value. So it should return 6 records.

SQL Calculation to 2 decimal places

I’ve got a simple calculation (910 / 28 = 3.5) and I’m trying to perform this in a SQL query: SELECT CONVERT(DECIMAL(5,2), (910 / 28),2) AS average But the answer is coming out at 32.00, I’m …

Oracle query all_tab_columns.data_default (type LONG)

I have run this query: But it throws an error at column DATA_DEFAULT: ORA-00932: inconsistent datatypes: expected CHAR got LONG 00932. 00000 – “inconsistent datatypes: expected %s got %s” How can I fix that? Thanks! Answer You can’t do anything with a LONG. It’s a PITA that Oracl…

Dynamic SQL output of a query to a variable

I would like to output the result of the dynamic SQL into a variable called @Count but not sure what the syntax or even the code should like to accomplish this. The code looks as follows: thank you Answer You can utilize sp_executesql to execute your count() query, and output it @Count. Try this: One last thi…

SQL invalid Identifier query

I am getting an error that grandvisit is an invalid identifier, and I am unsure if I will get it with other identifiers either. Any light shed on this would be amazing. As I cannot see why it differents from others. Answer You cannot refer the alias names in same select clause where it is generated. To calcul…

SQL basic issue

Part of a larger query. Initially I am getting an invalid parathensis message, I can get rid of this but am them getting invalid identifier error message, even though all the fields I’m using have been called. I am pretty new to SQL so any help would be great!. Answer Please use below there was two issu…

Split comma separated string into rows in mysql

When I have string list like 1, 2, 3… I’d like to use this as one column Is it possible by sql query? ex) SELECT Ids from (1, 2, 3…) <- I know this is not working. Answer Use a subquery of arbitrary digits to split your string.Instead of vals you can use ‘1,2,3’. See it workin…