I’ve written a query to return me the cities with the shortest and longest length strings in a MS SQL SERVER database. Select city, len(city) as l From Station Where len(city) in ((select max(len(…
How to check if a column is being updated
Let’s suppose I have an instruction that does the following: Is there any way to do it in Firebird, the same thing as Oracle does … The trigger would only be executed if it had only only updating the “active” column. I tried that way, but it’s not working: Answer Firebird doesn&#…
How to use variables in SQL query when using Python and pyodbc
I am using Python to extract data from SQL by using ODBC to linking Python to SQL database. when I do the query, I need to use variables in the query to make my query result changeable. For example, …
ORACLE SQL: Combining 2 rows of 2 separate select queries
Hello I am very new to SQL and I have an issue. I have 3 tables job, revenue and cost. job.unid = cost.job_unid and revenue.job_unid I want to find the total revenue and cost for each job and then find the profit for each job all on one row: The headers looking something like this: Job No, Total Revenue, Tota…
VIEW – INDEX SQL SERVEr
Does anyone know another way to run the query below more efficiently? I’m using SQL Server 2014. I’m facing a problem if i create index on table or on view . On table 2 (TB_FATURA_ITEM_TRANSACAO_HST) , has stored 50 million rows . I was wondering using Schemabiding on View , but I was looking in s…
Suggestion for a contact management database design
I am currently designing a contact management database for a chamber of commerce. The goal of the database is to store all the person (except our own staff), all recorded companies (regular companies and member of the chamber), addresses of the person and companies, tasks that the staff are currently responsi…
How to see full query in New Relic
When I go to APM > Applications > PHP Application > Databases it shows the list of queries and their performance. But the queries are shown like
select. How can I see the full query?…
How to join two tables with the same number of rows in SQLite?
I have almost the same problem as described in this question. I have two tables with the same number of rows, and I would like to join them together one by one. The tables are ordered, and I would …
SQL code patterns mapped to Matlab operations on `table’s`
I’m quite comfortable (and somewhat critically dependent) on Microsoft Access (SQL 92) code idioms patterns, including nested SELECTs, various JOINs, filtering, column ordering, and aliasing of …
TO_CHAR failing to set specific format in update
I’m trying to set a specific field in a record where the legacy code has used a DDMM format DATETIME as a char. I want to be able to find one specific value that matches something and basically change that one field. Super simple stuff, right? I know for a fact that if I query using to_char(SOME_DATETIM…