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
Tag: sql
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…
T-SQL :: generate random Swiss National Identification Number (AHV/AVS)
I woul like to generate random Swiss National Identification Number (AHV/AVS). I found a website that can do that and if I look at the source code of the same page I can alos see the JavaScript code that can generate it. The numbers are generated following this pattern: 756: is the prefix number, it never cha…
Why SQL (On-Prem using Data Gateway) Insert row (V2) action in Logic App does not populate tables?
I have an On-Prem SQL which I am accessing in my Logic App using On-Prem Data Gateway. I have created a table in my SQL database as per below: From a Logic App, I am trying to insert rows using “Insert row (V2)” action but it does not populate any tables: If I try any other SQL action in a
How to get count(percentage) for columns after each groupby item?
I have the following table. Using sqlite DB Item Result A Pass B Pass A Fail B Fail I want to realize the above table as below using some query. Item Total Accept Reject A 2 1(50%) 1(50%) B 2 1(50%) 1(50%) How should I construct this query? Answer You can try PIVOT() if your DBMS supports. Then use CONCAT