I’ve been reading posts about this and the so many suggested solutions didn’t work as I want. I’m trying to get the sum of some columns for the same rows then selecting all the other columns when …
MariaDB loop not displaying results of query
I have a simple query: SELECT COUNT(ud.UserID), COUNT(DISTINCT ud.ProductID) FROM users_data AS ud JOIN products AS t ON t.ID = ud.ProductID WHERE ud.UserID = ‘3’ Which results in: COUNT(ud….
SQL-Server I’m getting crazy with workday calculation with datepart
I’m working on SQL-Server 2012 and have the following code example to get workdays between two dates DECLARE @StartDate AS date DECLARE @EndDate AS date SET @StartDate = ‘2019/02/18’ — this is a …
Filter data in one table based on data in another table
I have two tables presented below. First table contains information about indexes. Each index can be applied to one or more columns. Second table contains set of pairs: table name – column name. I …
Group By clause changes the results
I have a query like SELECT weeks_ind, weeks_rol, weeks_no, date, CASE WHEN SUM(CASE WHEN rec = ‘Y’ THEN 1 ELSE 0 END) >= 1 THEN ‘Y’ ELSE ‘N’ END “rec”, CASE WHEN (SUM( CASE WHEN glob is null …
After Search in SQL Update a column value in the found rows
I have a DB table where a Field can have several different values, I want to update a field with certain values please see table below ID Name1 Place Number 1 Key TR 3 2 Lock BG …
join tables time difference of 10 minutes [datetime2](7) NULL
I want to join the values of 2 tables date for specific minutes . say data join for same date but hours can be + or – 10 minutes in difference. select * from table1 inner join table2 where table1….
Dynamic Extraction of text – SQL
I have a column with values in the following format: Successfully refunded 1 units of product 11111111 Successfully refunded 1 units of product 22222222 Successfully refunded 1 units of product …
Postgresql: Unique constraint over Union of 2 columns
I have the following tables: TRANSACTIONS id | amount —————— 1 | 100 2 | -100 3 | 250 4 | -250 TRANSACTION_LINKS id | send_tx | receive_tx ————…
how to retrieve latest data from a table
Currently I am working on a project where I need to extract latest data from a table for a report purpose. Below is the sample table structure:- Every student has several courses and course_id for …