Skip to content
Advertisement

Tag: sql

Add Column to Result of Postgres Dynamic Query

I have a table that looks like this: I rearranged it to this: Right now, the order of the systems is alphabetical but I created a mapping table in which it orders the priority of the systems Is there a way to adjust the order such that it reflects the priority and is as such: Answer You may find the

In go – gorm “mssql: Invalid column name ‘id’

This is my model in go } and this is my repo(that retrieve data from database): } On “http” I write this code with echo When I cal my ReadAll record rerieve data completly , it’s mean I conected to database currectly,But whene I try get data by “id” got an error that : mssql: Invalid column name ‘id’. Whet

Case in Sqlalchemy hybrid_property / expression error

I want to use expressions is ORM queries like this. Profile.query.filter(Profile.complete).all() Where complete is a calculated field Sqlalchemy docs shows the below So i’ve attempted to copy it with the following. But the output sql query is as below – the case isn’t compared agaisnt anything. So my output is all profiles, instead of only complete ones. What am I

SQL: Help creating a table based on another tables value

I am new to SQL and am currently doing a project on MSQL 2019. I have one table with a list of codes mapping a “Loss ID” to a Reason. Now I have another table that just gives you the number of the Loss ID but not the text version of it. How can I create a table that will

How to check consecutive values in rows in TSQL?

I have the following table: And I am looking for an output like this with a consecutive available two slots. Preferably the consecutive number should be a variable like @n = 2. How to achieve this in TSQL? Thanks! Update 8/3/2022: I undeleted this question as it is not fair to @lptr, as he/she has the correct solution, but didn’t

SQL Multiple join from 2 table to 1

I want to join from 2 table to 1. I have tried it multiple times but I can’t figure out the correct code. The name ‘Edvard Supica’ which is the full_name from suser table I want to be on the place of User ID and in 1 record. Answer If you’re joining both machines and susers on workbook, you can

Advertisement