How do I pass the greater than condition? I’m getting an error as invalid column name ‘average’. Here is my code: SELECT P.prod_cat, AVG(total_amt) AS average FROM Transactions T JOIN …
Tag: sql-server
Tag column values contained in other rows
Suppose I have the following table as an input : +———–+————–+—————-+——————+ | tableName | duplicate_Id | Index_name | Column_List | +———–+——–…
Creating unique row IDs in SQL using partition
I’m hoping that someone can either tell me where my syntax is wrong or let me know if there’s a better way to achieve my goal. I have taken a large dataset and applied a number of identifying fields …
“Could not find stored procedure” error when called from C# application
I created a stored procedure in SQL Server and tried calling it from my C# application but I am getting a message Could not find stored procedure I have already tried all possible solutions from &…
Can I use two values of a foreign key in on table?
I have a ‘users’ table, and there is also a table ‘alerts’. And in the ‘alert’ table, I want to use ‘users.id’ two times representing two different users of a ‘users’ table as a foreign keys in ‘alert’…
Get Values between Each Comma in Seperate Row in SQL Server
I need to insert multiple rows in a database table from a single string. Here is my string it will be comma-seperated values Current string: What I want is that batch 1 should be ignored or removed and remaining part should be added into the SQL Server database as a separate row for after each comma like this…
SQL Query, loop through data
I have a database with the following fields: UserID, DateRecorded and Score. A new entry is added to the table each time the score is updated. Here is an example of a user record: From the query I would like it to show me only the scores of all users with the earliest DateRecorded. Although not much familiar …
SQL Server 18 – merging dates around midnight
I would like to ask if anyone could help me with this. I have a table with user traffic on websites. The important column is Timestamp which looks like this. Timestamps are used to calculate sessions. An hour or so in timestamps means one session. The problem is that calculated session is different when the a…
How to flatten parent-child hierarchy from bottom up using CTE
for my first question on stack overflow I have the following problem, I’ve got an hierarchy table that looks as follows: The data looks as follows: the row with the wbe_node_type ‘leaf’ is the lowest level in the hierarchy, maximum depth is 8 levels deep. What I want is to flatten the hierar…
Save VB6 values in SQL
I have this interface: When the add button is pressed, a UserControl with the same fields is added: So, the question is: How do I save the main values and those that have been added? That is, if the user pressed the add button, how do I also save those values? Currently, this is the entire interface code: A…