I have such piece of program: What I want to do is write ‘<‘ in command in the same way as {table} and {pkey}, that means I want to pass operators into command from variable. Can I do it? The face of the app looks like this A little bit more of code context. It’s an app, that should get
Tag: sql
SQL: set trigger to get the sum of rows
This is the results table: I want to create a trigger that will sum up the rows get_ca1 + get_ca2 …+ get_exam and store the total in the get_total column. When the rows get_ca1, get_ca2,… get_exam are inserted, the trigger should calculate the total and store in the get_total column. I just learnt about triggers today so I’m not knowledgeable
MySQL trigger not functioning correctly
I currently working my AWS RDS MySQL through R notebook. I have a table like this: With a trigger like this I could create table and trigger without problems; however, when I insert something like this The insertion was successful but I would get an instance of fruit with ‘C’, instead of ‘A’ Wonder if anyone has some insights, thank!
Insert aggreated data from one SQL table to another (Postgres)
I have two SQL tables. This is Votes: and this is votes_aggregate: As you can see each entry in the votes table is a unique vote. I want to aggregate all the individual votes mapping to the same (catalog_item_id, listing_id) to a unique entry in the aggregate_votes table (2nd table). My Postgres skills are pretty weak so I’m struggling to
Understanding How to Parse SQL Solution
I am working on the HackerRank Top Earners problem. The problem states the following: We define an employee’s total earnings to be their monthly salary x months worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table. Write a query to find the maximum total earnings for all employees as well
Why am I getting an error when using the REPLACE function with a WHERE clause?
I am using SQL Server and SSMS. I have the following code: But I get the following error: Msg 174, Level 15, State 1, Line 2 The replace function requires 3 argument(s). I’d like to change G1 to G2 and C11 to C33. This is a small sample of a much larger code I’d like to build replacing many other
Google BigQuery: How to filter out rows by a particular column’s value frequency
Say that I only want to return rows where a column value occurs at least twice. I would do something like That works for just one column, but if I want to do return several columns but only have the filter apply to one column, it doesn’t work. My attempt is Which gives a “ColumnB which is neither GROUPED nor
Executiung performant SQL queries equivalent to “nested deletes”
Consider the following ERD for Order, Item and Article entities: I’d like to delete Orders satisfying a complex condition, and then delete Items associated to those Orders, and finally delete Articles associated with those Items. Cascade deleting from Orders to Items is possible as Order is a parent of Item. But cascade deleting from Item to Article isn’t possible as
SQL Group by Count String occurance
I am wanting to count the occurrences of a specific string in SQL. I have UserID’s which are unique and each user can carry out an “action”. I’ve tried a few things but still cannot get it to work. So these actions can be “throw” “pickup” “craft” userid COUNT(action) 7656119 129 76561194 4 Expected results required userid throw pickup craft
Postgres: avoid listing all columns (“must appear in the GROUP BY clause or be used in an aggregate function”)
This query works: but it’s very explicit and I’d like it simplified to: But this gives the error column “video_feed_unscored.title” must appear in the GROUP BY clause or be used in an aggregate function. Any other way to simplify the query? Answer Maybe not simplify but assuming, that there is a lot of feeds, and user see only few of