I currently have an account table and an account_audit table (all codes are available on a fiddle here). I have two triggers that insert records into the account_audit table based on data inserted into the account table. 1 trigger is an ON INSERT trigger which just inserts these values – that works fine…
Tag: mysql
using FETCH clause is not allowed in mysql .what alternative to be used instead
hi I have 2 tables want to use aggregation and having cluse. can u plz check my query? does not work Answer The nested aggregation MAX(SUM(registration.RegFeeAmntPaid)) is the problem: Nested aggregations are not allowed in SQL: After the first aggregation, there is only one value. Thus, aggregating again doe…
How to make a query that filters out only back to back values that do not have any other values in-between?
Write a query that returns all urls involved in a “bounce.” A url X is involved in a bounce if a single user navigates from a page Y to page X, then immediately returns to page Y while visiting no other pages in between. That is, you’ll want to find two visits X->Y (on date d1) and Y->…
How to make a query that filter out two AND conditions on same column
Write a query that returns all pages that have been visited by at least one child (demo=’child’) and ALSO has been visited by at least one person aged 18-25 (demo=’18-25′). Your query should return a set of urls. I am not sure how to write a query that filters out results based on Two …
How to convert SQL statement to Power BI DAX?
I have no idea how to recreate the following code from SQL to DAX in Power BI: Or perhaps there is a way to operate on SQL commands in Power BI with imported and filtered tables? I want to do the SQL query on the already sliced data in Power BI. Thank you in advance 🙂 Answer You can achieve
SQL MAX on primary key, is filter condition unncessary if it is already indexed?
id is the primary key. Is date(created_at) = ‘2021-11-05′ and time(created_at) > TIME(’04:00:00’) filter condition unnecessary for Max function since studenthistory is already indexed on class_id and student_id? The only reason I added that datetime filter is because this table will…
Why doesn’t the WHERE work in this sql query
I’m writing a SQL query that needs to only show the results where the ‘titel’ is the same as ‘Baklava’, but it doesn’t return any rows. When I try to use the query without the WHERE, is shows all the results, but I need the WHERE clause to work. Here is the query I’m …
SQL insert multiple values and parent id by selecting from same table
How do I insert multiple values and parent id by selecting from same table I tried below and getting an error MySQL said: Documentation #1093 – Table ‘ctg_tbl’ is specified twice, both as a target for ‘INSERT’ and as a separate source for data Answer Your query can be made to wor…
What part of my query is invalid with MySQL 5.7?
I have created the following query: It works during development but after testing it on the production server (which is uses MySQL 5.7) I get the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘cte1 A…
Implement database schema for organizing historical stock data
I am new to MySQL, I try to use MySQL to store my stock data. I followed the answer by boe100 in reference: Database schema for organizing historical stock data I create my table as follows: mysql> describe StockDailyQuotations; Field Type Null Key Default Extra ts_code varchar(9) NO PRI NULL trade_date in…