Is it possible to use bind variables in a Teradata dynamic SQL statement? I can’t find an example anywhere. I’m looking to do something like this: DECLARE SQLString VARCHAR(1000) SET SQLString = ‘…
Tag: sql
Query to find the city name with longest and shortest length
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’t have anything like updating. You need to compare
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, Total
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 some articles that is not
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 responsible for, a list of our staff (user) and the
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_DATETIME, ‘DDMM’) = ‘0311’
How to find group which is having Status Active? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago. Improve this question I have a id which is having more than one Accountid in a table with status Active . I need to find group of active