I have the below table from which I need to filter which holds both “g / ml”. The below query gives me result as The expected result is What I can apply in the where clause to get the expected results Answer Just use %g/%ml%. The % can appear in any position in the matching pattern.
Postgres conversion rate
I want to get conversion rate in postgresql. My data look like below: input: id count type converted 1 30 A true 2 20 A false 3 13 B false 4 7 B true As first step, I would like to get a sum of counts for each type with associated count field. I tried with different variations of SUM()
MYSQL Query Age Calculation
This is my MySQL Query to return the age from the date of birth The query is executed. But it returns the age difference is in a negative value. Answer The problem with 2-digit year fixed – all years are treated as 19xx. https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=f356258c99b20d13b0c4e2349b801f18
SQL query for key value table with 1:n relation
I have a table in which I want to store images. Each image has arbitrary properties that I want to store in a key-value table. The table structure looks like this id fk_picture_id key value 1 1 camera iphone 2 1 year 2001 3 1 country Germany 4 2 camera iphone 5 2 year 2020 6 2 country United States
Select distinct very slow
I have a table where I store rows with external ids. Quite often I need to select latest timestamp for given external ids. Now it is a bottleneck for my app Query: Explain: What could I do to make this query faster? Or probably should I use completely different query? UPDATE: Added new query plan as asked @ja…
Error – NetTopologySuite( When writing a SQL Server geography value, the shell of a polygon must be oriented counter-clockwise)
All, I’m using NetTopologySuite/ Entity Asp Core for my project. I want to create a radius of 1000 meter for the ‘searchArea ‘ When I’m running the the app it gives me an error : System.ArgumentException: When writing a SQL Server geography value, the shell of a polygon must be oriente…
SQL count by type
I would like to summarize in a table so that I have for each id in each round, the number of tokens “red” and “blue”. What would the SQL query for such table? Here’s the data. The result will display like below: I have been trying the following code: Answer I would suggest this to get to the requested r…
T-SQL :: information_type is not parsed in SQL Server 2019
My query doesn’t seems to parse information_type STEP TO REPRODUCE: Take AdventureWork or any other test database Right click on your test database > Tasks > Data Discovery and Classification > Classify Data… and classify a bunch of data Now use this query to check your information_type c…
What is wrong with the WHERE clause in this SQL query?
I fixed the syntax errors and it still won’t run. I keep getting the following error: unknown column ‘tblProduct.id’ in ‘where clause’ Note that there is a column ‘id’ in the table ‘tblProduct’ Answer MySql does not support full joins, the error does not d…
Using GROUP BY and JOIN-ing non-aggregated columns to query
I know there are many similar questions, but I haven’t managed to solve my problem by reading them. I’d appreciate some pointers. Here’s some example data from my dummy table below: id foo bar baz moo ins_date percentage yes no maybe 38 foothing bar_one pizazz amoosing 2018-05-26 06:59:00 81…