I have a table like this. create table public.test123 (id int not null primary key, dt timestamp null default clock_timestamp()); I then insert into it from 2 different client sessions, the first …
Connecting two queries to get Cartesian product
I have a query SELECT d.GUID, w.word FROM dictionary d JOIN word w ON w.ID = d.ID_word WHERE w.id_language = #ID#; if #ID# = 1 it returns table GUID | word ———– 1 | A 2 | B 3 …
sql to r – select cases
I have included a lot of sql code in R using the sqldf library. Since this is becoming increasingly hard to digest, I would like to do it using, for example dplyr in native R. How would I do it for …
Concatenate in sql teradata
I have the following code Sel account, Div, Modl, Sub_modl From table_1 Where Div gives me 01, Modl = 1 is CS, and Sub_modl=1. I should combine these fields to have: 01_CS_0101 Where the first 01 …
Does join speed depend on total amount of records in the table?
If i have a table that looks like this (composite PK user_id + asset_type): |user_id|asset_type|amount| One user have at most 10 records in this table. Imagine if there 200 millions records and i …
Stored procedure with string as parameters not working -SQL
In my database ‘Student_name’ is set as varchar. And the stored procedure is: ALTER PROCEDURE [dbo].[SP_STUDENT] @STUDENT_NAME NVARCHAR(MAX), AS DECLARE @columns NVARCHAR(MAX) = ”,…
Row comparison in table via SQL
I have a table which is structured like the following: Is there a way to build a SQL query which – per each ID – looks for the Day in which Value1 OR Value2 has changed? The result I would like to achieve would be this: In which I can keep track of those changes per ID per Day. Edit:
How to determine all details should go to first line item if we have multiple duplicate dates?
1)I have four fields like material no, item no, date, quantity. Input: Material item date quantity 101 91 06/05/2020 4 101 92 06/05/2020 …
SqlCommandBuilder Update Command is Generating Command but Not Updating Database From DataGridView
I am inheriting a form class (Form1) for Form 2. Form 1 code works without error. In Form 1, I use SqlCommandBuilder(SQL.DBDA).GetUpdateCommand to generate the update command for my Datagrid to pass to SQL data table which again works perfectly and the table is updated successfully. The SQL command text for F…
inner join with subquery results differs for these data sets
CREATE TABLE IF NOT EXISTS `wcd` ( `id` int(6) unsigned NOT NULL, `wid` int(11) unsigned NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; INSERT INTO `wcd` (`id`, `wid`) VALUES (‘168’, ‘…