Skip to content

Tag: sql

Perform counting for lookup in SQL

I would like to perform lookup based on the number of Yes in Input. In ID No.1, Output1 is A because it is first Yes, Output2 is B because it is second Yes. In ID No.2, Output1 is blank because Input1 is n/a, subsequent output is based on number of Yes appeared. In ID No.3, it shows counting is skipped

MariaDB : an INSERT…SELECT with empty VALUES too

I want insert data from another incomplete table, so some values must be empty in NOT NULL fields. For example, I have two tables : people and peopleTemp. In people table, I have a lot of fields : permit_number, first_name, last_name, gender, tel, etc. In peopleTemp table, I have only permit_number, first_nam…

C# SQLConnection.Open() hangs, with no exception

I am using C# in Visual Studio 2019, with Xamarin.Forms, and SQl in SSMS 2018 and have the below code (where [] is used to replace unneccessary information) When I run this, it hangs indefinitely at connection.Open(). Debug mode continues to run and appears to move on from Connection.Open(), but never reaches…

Group rows by datediff and then use diff function

I have table in PostgreSQL with timestamp column created_at and integer column user_id. Each row represents some action from user. I need to calculate average user session length. Session is defined as group of actions with time difference less than 10 minutes. When there is difference 10 minutes or more betw…