Skip to content

Tag: sql

Complicated PostgreSQL query to group by multiple columns

I have PostgreSQL table with client_id, date, smp_number, vs_type, vs_amount: What I want to achieve is to group by client_id and month and then to get the total debit sum and the total credit sum by month in distinct columns and the last smp_number in each month. The result should be: Hope this makes sense, …

Display rows where multiple columns are different

I have data that looks like this. Thousands of rows returned, but this is just a sample. Most days have the same numbers in them, but some do not. Note that ID 1 and 5 have identical numbers every day. ID Sunday Monday Tuesday Wednesday Thursday Friday Saturday 1 26 26 26 26 26 26 26 2 44 44 30

Filter an XML column in SQL Server

I have an xml type column productsXML in product table I want to find all the rows that have <products></products>. I tried this: This is returning all the rows that have products tag and understandably so. Is there a way to filter only those rows that have <products></products>? Answe…

Self join to update table in SQL

I have the following table: Category Qty Orders Level Product 0 Part 1 2 4 1 Part 2 3 5 1 Part 1.1 4 6 2 Part 1.2 5 7 2 How can I update the above table’s Level 0 row with sum of Qty and Orders (excluding Level 0’s Qty and Orders)? i.e. Category Qty Orders Level Product 14

Select integer column as corresponding letter of the alphabet

I have an int column that contains values no larger than about 20. I want to select as its corresponding upper case letter of the alphabet: I don’t care what happens after Z because the column doesn’t contain larger values. Is there a simple way to do this with a SQL query, to convert to a single-…

Azure Synapse is failing to perform the deployment giving error “type Microsoft.Data.Tools.Schema.Sql.SqlDwDatabaseSchemaProvider is not valid”

I am working on Azure Synapse. I am able to build the Azure Synapse project successfully using the Azure CI pipeline’s MS Build task. But as I am trying to deploy Azure Synapse using the Azure CD pipeline, I am getting the following error. I am deploying the DacPac using the following task. I hope this …

Import dump file containing a database dump to dbeaver

I have a database dump in thisdb_2022.dump binary file that I’m trying to import to dbeaver, but I haven’t found a way to import the database so I can see it. I found the below in the dbeaver forum but when I try to follow the instructions and create a new connection I don’t see any option I…