I’m working with a custom DBMS (compliant with SQL 2011 Standard), and am trying to combine multiple columns into a single column like so, but am struggling with the syntax: Current table: Desired query output: I’ve tried various IF and CASE statements, but have hit a wall. Any help would be appre…
Tag: sql
SQL Query, loop through data
I have a database with the following fields: UserID, DateRecorded and Score. A new entry is added to the table each time the score is updated. Here is an example of a user record: From the query I would like it to show me only the scores of all users with the earliest DateRecorded. Although not much familiar …
SQL Server 18 – merging dates around midnight
I would like to ask if anyone could help me with this. I have a table with user traffic on websites. The important column is Timestamp which looks like this. Timestamps are used to calculate sessions. An hour or so in timestamps means one session. The problem is that calculated session is different when the a…
Stored procedure can not be called due to syntax error
We migrated from SQL Server to Postgres and I am trying to rewrite a stored procedure. The procedure is created correctly, but I can not call it. This is my procedure: CREATE OR REPLACE PROCEDURE …
Nasty sql error(POSTGRES) “There is no unique constraint matching given keys for referenced table…”
EDIT: tables have been translated from my language to english i’ve changed te reference of foreign key in table Comment to “Utente” -> “User” Hi everyone i’m trying to build a small review system in sql as follows. Every user can comment on some item(could be anything) a…
How to flatten parent-child hierarchy from bottom up using CTE
for my first question on stack overflow I have the following problem, I’ve got an hierarchy table that looks as follows: The data looks as follows: the row with the wbe_node_type ‘leaf’ is the lowest level in the hierarchy, maximum depth is 8 levels deep. What I want is to flatten the hierar…
Save VB6 values in SQL
I have this interface: When the add button is pressed, a UserControl with the same fields is added: So, the question is: How do I save the main values and those that have been added? That is, if the user pressed the add button, how do I also save those values? Currently, this is the entire interface code: A…
Pass subquery value to IN statement
In one table named prefs, I have a column named “Value” of type clob that holds this value: ‘T’, ‘L’ I need to query table attendance_code to retrieve the records where column att_code values are either T or L. The att_code column is of type varchar2. As a manual model quer…
Do Changes Made on Table Created by Joining a View and an Another Table Affect Original Table View Based On?
Suppose I have a view created on a table. If I change some record on my view, the original table is also changed too. What if I join this view with an another table and change some records on this …
Date of last day of week in Firebird 3
This is a date of first day of week (monday) in Firebird 3: DATEADD(DAY, (EXTRACT(WEEKDAY FROM D – 1) * -1), D) And how to get the date of the last day of the week (Sunday)? In Firebird: Mon = 1, …