I am trying to use left join in subquery in SQL Server. My query looks fine to me but it gives syntax error. This is my query: This is the error I’m getting: This is my table structure: Answer As @Chris mentioned, the query is bit incomplete. I guess you are trying to do something like this: This query …
How add more rows when find string in column Oracle
Would it be possible to add more rows base on Keyword string in SQL ? table A table B Example: Output of the SQL should be – How to find string with keyword ‘FamilyCare’ in PromotionName of table A base on promotion_code of table B? If it exist it will add more rows in output Any help with t…
insert datetime from csv to postgres error
I have a csv file: output: And then I tried to insert the file data into postgres database: Error: It works in psql client. I thought it is the string character ‘T02’ issue,so I use: Then the error became: Then I thought I need convert it to datetime first: Same error as the last one. Then I did s…
Query to list columns where some values are not available
I have two tables in a database that look like this: CREATE TABLE PAR ( A varchar(10) not null, T varchar(25) not null, U varchar(25) not null, V …
MySql view with group_by very slow
I have two tables, appointments and clients. The tables are big, each with about 100M records. each has a primary key on id clients has a foreign key on appointment_id I’m using mysql 5.7 As one would expect, the following query is lightning fast: But, if I create the following view and query, it is int…
sql query to exclude results if criteria is met
i have a query which selects name, appointment date and their status icon. I want to exclude any records for the person if they have a status icon of 3. Such as below: name appt date status icon bob …
What is the purpose of using `timestamp(nullif(”,”))`
Folks I am in the process of moving a decade old back-end from DB2 9.5 to Oracle 19c. I frequently see in SQL queries and veiw definitions bizarre timestamp(nullif(”,”)) constructs used instead of a …
SQL Server – Getting initials from a list of names
I have a table containing a list of employees assigned to a certain project. A bit like this : ID Employees 122 Mark Doe 210 John Doe 212 Julie Doe, Yuri Doe I have to transform the Employees column …
LEFT Join on a Subquery with specific criteria
I have two tables that I am trying to JOIN I am attempting to Select from table1 a and LEFT JOIN table2 b on a.id = b.id – however, I want to only select on the id in table2 where MAX(EndDt) Is something like that doable? Answer There are a few ways you can do this. I make some assumptions
Separate user role in SQL
I have a table called user_role_link where the column are userid, roleid, bitlive and bitdeleted. This table links to the dbo.user_role where in here I have columns roleid, DescriptionRole I want to extract all the users with introleid in (256, 308, 313) but not to be part of this roles: introleid NOT IN (225…