Skip to content

Unable to Query XML Document with SQL/OPENXML

I would like to query the following XML-File using SQL: Using this code I would like to get the value for “mRID”: However, the result is: mRID NULL How to get the correct value for mRID (‘2f6f8b82348440b1b121bca06311945d’) instead of NULL? Answer Microsoft proprietary OPENXML and its c…

WHERE followed by ON clause

What is the semantic difference between the following queries? To me both seemed similar until I executed them on presto. Is this something specific to presto or am I missing something in the SQL standard? Form 1: All conditions specified in the ON clause. Form 2: Some conditions specified in the WHERE clause…

Combining 3 Tables and Finding Average Age in SQL

I need to combine three tables and find the average age after combining the three tables using SQL. The name of the age columns in the three tables are pr16pnk.age, pr16puf.age, and pr16yag.age. I have successfully found the results when the tables are separated, but I am having trouble combining the results.…

Performing subtraction in SQL/finding the balance

SQL table here: http://sqlfiddle.com/#!9/abe1da/9 Current Table: Year Month Type Accounts Amount 2021 1 Actual abc 20 2021 1 Actual def 30 2021 1 Actual ghi 40 2021 1 Actual X 7 2021 1 Actual Y 3 2021 1 Actual final 105 Expected Year Month Type Accounts Amount 2021 1 Actual abc 20 2021 1 Actual def 30 2021 1 …

Filter coming result in same column

Pointid Productid 5 24 6 24 6 25 6 26 7 24 7 25 7 26 7 27 For the query: The result is: 5,6,7 But I want only 6. No more No less.. How can I do it? Answer The main goal is to find those pointid where their productid are EXACTLY 24, 25, 26. Importantly: no more, no

Calculating a plug/balance in SQL

My current table has a few accounts which always have minimal values (example, X & Y for actual and AA, BB, CC & DD for plan) in current table. Accounts with minimal values can extend beyond these accounts. I need to categorize such accounts into proxy account called “balance” which would …

Passing integer value from textbox in SQL select statement

I have an integer in a textbox(Integer retrieved from another form using TOstring) I want to use in an sql select statement. For example, select * from table where column = textbox. The problem is, npgsql gives an error saying I’m trying to pass string into integer column. I try to cast(::int) but still…

Convert sql query to EF

Can anybody please help with this SQL query to transform it to EF Linq Expression? I’ve been trying to do this for days, so I could really use some help. Do you need extra info? Thank you in advance. Edit Here is a little part of the diagram, maybe it helps Answer It seems the subqueries in both of your

PostgreSQL query update returns UPDATE 0

I am having trouble with a PostgreSQL query where my update condition contains more prerequisites. I attached 2 images to describe my problem. I want to update the highlighted row But the response is: Answer Your problem might be somewhere else (see this db<>fiddle) A few thoughts on your data: Reduce t…