Skip to content

Tag: sql

SQL CASE Expression

I need to write a sql statement(Oracle) where I can withdraw data from two diff tables and check for a condition and return a certain string. My statement goes like this, When I run this I get a error: “FROM keyword not found where expected”and points to the c in line 2. and if I change the from t…

I need to optimize tables and queries

I have 3 tables: info, data, link, there is a request for data: offer optimization options: a) tables b) request. Queries for creating tables: Thanks! Answer Never use commas in the FROM clause. Always use proper, explicit, standard, readable JOIN syntax: Second, for this query your indexes are probably fine.…

Grant Select To Synonym For Specified Columns

I’ve been trying to restrict a user’s select access to a synonym. Consider the following below: I get an error: Msg 1020, Level 16, State 3, Line 4 Sub-entity lists (such as column or security expressions) cannot be specified for entity-level permissions. But if I change it to use dbo.Items direct…

Correspondence between two tables

I have table the table code_Commune contains gps for the city in general code_Commune: Now I need to do correspondence with the table lead to add code_commune and Nom_Commune: Table lead Is there any way to do correspondence between the two tables? Answer You can find the closest city using some sort of dista…

String concatenation in SQLITE with NA values?

Currently working in SQLite and have the following table I would like to create a new column – which is the concatenation of the columns subject_1 and subject_2, however I have values within my subject_2 column – is there a way of concatenating the columns so that I can get the following table Now…