I have an SQL table with the column named expenses like this I want to write a query to return all the elements of this column separated by a comma. For the above example output should be:- hotel,…
Tag: select
Find schema name given table name in Redshift
Is it possible to retrieve the schema name given the table name in redshift and return an error if table is not found? SELECT * FROM PG_TABLE_DEF WHERE tablename = ‘tablename’; doesn’t seem to work. Answer pg_table_def lets you see only the tables that are visible to your curent user – which, presumably, is not the case of the
mysql get result from join table
I have a tables person and exam. I want to show data where all exam is PASS, show the latest exam pass_date. like table below what query to get it? please help. thanks! Answer You can use aggregation and conditional expressions: Note that for this sample data, you don’t need to bring in the person table to get the results
How to use select statements for column name ending in +
I am attempting to run a spearman correlation on some data under the column name solar+. However, when attempting to use select statements to select the desired number of rows from the egauge13830 table, the plus sign is considered an operator and causes an error. These are the 2 statements I’ve tried and their results: 1) sqlalchemy.exc.ProgrammingError: (psycopg2.errors.SyntaxError) syntax error
select current address
I am new in sql and have a table as folow: patientid |gender|yearbirth|zipcode|admission | ———–|——|———|——-|——————-| P1213060727|w | 1926|55268 |2017-01-23 16:28:00| P1213060727|w | 1926|55270 |2018-09-26 18:10:00| P1213060729|w | 1956|55262 |2018-03-09 09:51:00| P1213060731|m | 1935|55276 |2015-02-11 16:54:00| P1213060762|w | 1945|55452 |2011-01-19 15:30:00| Some person have two address and I need the list of patients with the current address. patientid |gender|yearbirth|zipcode| ———–|——|———|——-| P1213060727|w
SQL request to Clickhouse: select if value exist in JSON array
I’ve got a following table: How can I do ‘select Status where Name XXX represented at least in one Array[i].Name’? Answer
SQL query NOT EXIST very slow
I’m trying to optimize an SQL query as it is slow, and gets slower when the query result is high. There are indexes concerned fields and Tables are quite big. Answer As a starter, this condition: Should be rewritten as: This is functionally equivalent, and not using date functions on the column being filtered gives the database a chance to
How to list out management levels from Postgres table
I have a table with the following fields: Id, manager_id, and candidate_name The manager_id will point at id which allows me to reference the management chain. I want to generate an output like the …
How to query rows depending on multiple to-many properties?
I have one-to-many relation between tables user and tag: Users: id username ————– 1 Bob 2 Alice 3 Eve Tags: id user_id name ——————– 1 1 …
Select field based on other column max value in oracle pl/sql
I am calculating a field called “Degree Level” in a view. This is a field in the table “Degrees”, and the table shows degrees for each faculty member. A faculty member can have more than one degree. The field “degree level” is also in the table “Crosswalk_Table”. I want to choose Degree level for a faculty member based on the