Lets say i have a table with posts, and each post has index of topic it belongs to. And i have a table with topics, with integer field, representing number of posts in this topic. When i create new …
SQL average money spent per day
I would like to get some help in writing SQL query for the table below. The table represents how much students spent at a food court on a given date. With this table, write an SQL query that …
How To Find Perfect Match With Multiple Rows Across Tables?
I’m looking for a way to find out which collection of lines from #Orders matches with #Pallets the best. With the example below with @palletId = 1000 as input to the query the results should only be …
Why don’t these sql statements work together but work when i execute them separately?
CREATE TABLE test_table(id int not null auto_increment PRIMARY KEY, year int, quarter varchar(2), month varchar(3), week int, fiscal_month int, fiscal_week int, bsv int, prod_bsv varchar(50), …
How to display Max Date amount in another column?
I want to derive column MSP_ADULT and MSP_CHILD based on the LATEST date record ADULT_AMT to be in MSP_ADULT and CHILD_AMT to be in MSP_CHILD column. I want to my out like below. Here is the code I am running, but it is not working. Answer So you want the last values of those conditional MAX’s. Try FIRST_VALUE with a
Oracle – wrong result using sysdate
I have the following query. This query does not return any result: select snap_id from perfstat.stats$snapshot where snap_time = sysdate; no rows selected but if I format the snap_time and sysdate …
How to store code/programs written in any programming language in SQL Server
I have to display some C# code on a page of my web application (ASP.NET MVC application). How can i store C# code (program) in SQL Server ? Consider that i have the following code: public class …
What is the best way to add image and numerical data to the database at once?
I guess this should be straightforward. I have a table in SQL with the following columns: [CaseName],[Rev],[S1],[S2],[S3],[S1Im],[S2Imbef],[S2Imaft] the last three columns are images. I want to add …
Is there a better way I can structure my tables, do a 4 table join, or will I have to perform multiple queries?
What is the correct way to perform this GET request? I currently have 4 tables: events, event_comments, event_photos, event_users_going The last 3 tables, event_comments, event_photos, and …
SQL database error exception in c# using VS 2019 edition
I am new to C# database and I have been battling with this error for a few hours. When I created the table, I used ctrl + s to save it but it saved like normal saving into My Documents which I think …