I don’t know if the question make sense or not. I’m trying to request information from 2 different tables that are linked (via FK) to a table and display the data with information from that linked tables. post user role Is there a way to select/show this table?: result Answer Try this:
Tag: database
Redshift SQL: Column Counting Matching Rows Given a Condition within another column
I have a table with two columns, user ids and strings. I want to add a third column that counts the number of strings within the second column that start with the entire string value in any given row. There is only one row per user. The goal is to get the following table structure: Here the count is equal
SQL: How can I pick a cell value from one table as a condition to select another table
Hi I’m a new learner of SQL. How can I realize this process in SQL or perhaps with python if needed: First, from table1, I randomly selected two results: I need to use the value x and y as conditions to display another table. For instance, using x, I can: What I need is to get the length of table2
How to count and order correctly result from table
I have like this task currently: (sql fiddle: http://sqlfiddle.com/#!9/431723/49/0) It is necessary to form a SQL query to the files table which displays the number of files based on the success of the conversion and the presence of a good rating from registered / unregistered users. Output format: user_type (‘Visitor’ if id_user = NULL; ‘User’ otherwise), flag_converted, is_best_rating (‘1’ –
Getting Incorrect results for selecting values between 2 dates
I am trying to run the below query to select some results between 2 dates but I am getting results as the condition doesn’t exist. So what is wrong here? Answer You are comparing dates with strings; the dates are converted to strings to do that comparison. From the documentation: During SELECT FROM operations, Oracle converts the data from the
Is there a way to SELECT a database table using a variable?
I tried this statement: string query = “SELECT question FROM ‘” + GlobalVariables.dbQCode + “‘ WHERE [question_code] = ‘” + GlobalVariables.questionCode + “‘ “; and when I run the code it is giving me an exception: Syntax error in query. Incomplete query clause. Is there a way where I can use my variable? I want it to work because I
SQL server Change Column datatype on 1K million records
I am facing the column length issue in my table and I want to change column type to big int from int and table rows around 1K million records but when ever I tried to change data type it is taking to much time and it is eating my machine all space, what is best way and fast way to
Trying to figure out a sql query to fetch the right data from multiple tables
So I have a database and I have 4 tables (admin, appointment, doctor, patient). I only care about appointment, doctor and patient. Diagram of these 3 tables: What I want is based on a patients amka(int) to find all his appointments and show his name, surname and doctors name, surname. I made this query: The problem with this query is
Making a table with a foreign key
I’m creating a SQL database in Oracle. I have created this table: And I tried creating a second table that has a foreign key referencing it: I get this error: ORA-00904: “LID”: invalid identifier 00904. 00000 – “%s: invalid identifier” Answer Defining a foreign key on a column doesn’t create the column. You need to create the column first and
MySQL select unique records from one table with two select queries using NOT IN
TaskNumber JobNumber Status Date 11111 JS0001 0 04-06-2021 11112 JS0002 0 05-06-2021 11113 JS0003 1 05-06-2021 11114 JS0001 1 06-06-2021 Table Tasks. TaskNumber is the unique id(primary key). Status 0 is not done, 1 is done. example: JobNumber JS0001 assigned on 04th of june and not done, so reassigned on 06th of june and was completed(status 1) How do i