Sub query, SQL, Oracle I’m new to sub queries and hoping to get some assistance. My thought was the sub query would run first and then the outer query would execute based on the sub query filter of trans_code = ‘ABC’. The query works but it pulls all dates from all transaction codes, trans_c…
A problem with a simple join taking too long to finish
I´m having trouble identifying who to fix this simple join. My problem is, after adding the column B.CIDPRODUCT IS NULL this query takes hours to finish. table BO_PRICER001 rows 286537 table BO_PRODUCTCONFIG rows 7934844 on the table BO_PRICER001 exists 15329 rows with null with B.CIDPRODUCT IS NULL the live …
replace value with 1 and apply SUM method in one query SQL
I need to replace the value in column imp from 1-0 to 1 and sum it up. Column imp is a STRING, so it also needs to be converted to INT. Each line represents the record so I need to sum up imp and group by another column (in order to get the number of records for a specific Advertiser)
Use a common field in two tables with XML in SQL Server
How delete the redundance in the table #XMLItm? My code: In this code I want load information in two tables for a common field ID_LIST. How load the ID_LIST from #XMLLst in the temp table #XMLItm? I want delete the field ID_LIST from XML in the table #XMLItm and take a ID_LIST from temp table #XMLLst; Functio…
How to stop DB inputs for a certain amount of time from all current users
So I’m making a php website that sometimes requires a big data input from an admin-type user. This would not be frequent and only would happen to update or add certain data to the DB. During this upload time which probably will take a minute or two, I cannot have other Users try to pull the data and and…
Total value of warehouse active record
I have the object Tool and I need to calculate the cost of all the Tools in the warehouse. I can sum the column price Tool.sum(:price) but i need to sum (quantity * price) of all the table Tools. Thanks in advance. Answer Check out the example listed for ActiveRecord::Calculations#calculate. You can do the fo…
Missing expression inside sub-query statement?
I am using the infamous “CityJail” schema to answer a question “List the names of all criminals who have committed more than average number of crimes and aren’t listed as violent offenders.” Here is my code: but I get an error: ORA-00936: missing expression 00936. 00000 – “…
How to add a category to the results of a query based on the output?
Extending this question for a more general case: I have a table called fruits with a column fruit that has three possible values: apple, orange, and mango. I used the following query to get the …
MySQL Scoring of values from select across rows and multiple columns
So I have a scheme like the following: | phone1 | phone2 | phone3 | phone4 | phone5 | phone6 | | ————- | ———– | ———– | ————- | ——–…
SQL select only one row from second table JOIN
I have the following tables Channel | id | name | descr | channel_user | channel_id | user_id | channel_text | channel_id | text_id | text | id | text | time I am trying to retrieve all channels a …