Skip to content

Dynamically fill an SQL table by detecting a name?

I want to dynamically fill a SQL table by detecting duplicate names. So, when I use an insert statement on this table – if the name already exists it adds an entry with the same ID. What I mean by this, for example I’ve got this empty table: Table Domain: DomainID Name URL StatusID ErrorID Date So…

Transpose row to column in SQL Server

I have a table like below: The first row is the header. Now, I would like to transpose table into this I have tried unpivot but the result is not desired table. Thanks in advance, Answer I recommend using cross apply to unpivot and then aggregation: I much, much prefer this over pivot/unpivot. Why? APPLY impl…

SQL select with case when and join table

I have 2 table in sql (postgresql) tbl1 : dates roomid stok 2021-03-15 A01 3 2021-03-16 A01 3 2021-03-17 A01 3 tbl2 : bookingcode startdate enddate roomid B001 2021-03-15 2021-03-17 A01 My …

SQL Update record when field is in the past

how can I set all records in the field “published”=0 whose date in field F12 is older than today? Unfortunately, the field F12 is not a DateTime field, but a string. Unfortunately, I can’t …

SELECT statement across multiple tables

First off, I am not an SQL coder. I am trying to select information from 2 different tables in the same database. Table 1 is called trans and has 3 columns: Table 2 is called cust and has multiple columns: The SELECT statement that I’m trying to write will pull data from both tables. I THINK I need to u…

oracle add column with value based on condition

I would like to add a column “tag” based on value of “LEASE_ID_count” with ORACLE. But i get this error : value too large for column “CUSTOM_LIFETIME_VALUE_TAG”.”tag” (actual: 7, maximum: 3) , caused by: OracleDatabaseException: ORA-12899: value too large for co…