I have a table with 4 columns such as Customer ID, Person ID, Year, Unit Cost. I want to join the same table with all the years from table and keep the all years for all customer ID and PErson ID’s. IF there is no data in the table for respective customer ID and PErson ID then I want the
Tag: sql
Calculating a 7 day average
I have this query. I want to generate the 7 day average of the mappings column. For example, I want to calculate the average mappings for each day (from 2020-01-03 – 2020-01-10). Results: Then return avg(avg_mapping) Answer I don’t see how your question relates to a rolling average. From your data…
mysql – fetch related rows from multiple tables without all combinations
Let’s say I have a primary table record, and it has 2 related tables fields and comments. I would like to run one query that fetches a set of records AND fetches all the related fields for that record, AND fetches all the comments related to that record. If I do left joins to ensure I get the records, I
How to list all schemas and tablespaces in Oracle from .dmp file without importing?
So, the problem is that I have the .DMP file that was exported by a customer using exp or expdp. I want to get some of the .dmp properties, as I do in SQLServer using the following command: RESTORE HEADERONLY FROM DISK = N”C:tempmyfile.bak”; The original tablespace and schema are the infos I need …
Count how many times a rows enter time is within the enter and exit times of all other rows
I am looking to estimate a queue length for historical data at the time a record enters the queue. I would like to do this by counting how many of the rows in the data set have an enter time less than the enter time of the record, and an exit time greater than the enter time of the record.
How to Get list of ids from same query when returning as JSON
apps table I have a query, SELECT * FROM apps WHERE app_status = “ACTIVE” FOR JSON PATH; This query has an app_id field. I also want a field to accompany the json output with a field ids with all the app_id as a list. So instead of: I would have: Answer This returns the correct JSON Data Query Out…
UPDATE ACROSS JOIN SYNTAX
I am trying to get an update statement to function how I need. I’ve tried the following with INNER / OUTER LEFT / RIGHT JOINS. I continue to have records that are not updated in the usertype2 table despite having usertype3 child values. Am I going about this the right way? Usertype2 and Usertype3 will a…
Reference to database and/or server name is not supported in this version of SQL Server
Objective I’m trying to put data from a couple different Azure databases into a new Azure database with a script similar to the following: Essentially I am creating the tables in the new database with the exact same schemas that are in the source databases and then trying to insert all of data from thos…
The multi-part identifier “t7.rate_buy” could not be bound
Please help me on this error message: The multi-part identifier “t7.rate_buy” could not be bound. I can’t find how to fix this. I use SQL Server 2012 and I have tried everything but I can’…
Datalist Control not showing any Paragraphs
I have a datalist control that gets populated from a htmlTextEditor control. The Datalist is ignoring all my paragraphs. In the htmlTextEditor I Enter: Test – Please Ignore Test Test Test But the Datalist shows Test – Please IgnoreTesttesttest What is happening here??? Help!! In the Database the t…