I have a simple query but it keeps throwing “Invalid use of group function”. It works fine when I remove “count(*)”. How can I get the count without using it in lag? Answer Hmmm . . . MySQL should allow the use of aggregation functions with window functions. Maybe there is a bug in the…
Tag: mysql
How can I efficiently query for all rows in a database matching a filter based on a joined table?
Apologies if the question title is unclear; I’m not sure how to phrase this without more detail. I have a table foos like: id (bigint) | details (json) 1 | {someKey: ‘someValue’ …} 2 …
SQL JOIN to grab multiple tables with no relational criteria
How can I use the SQL JOIN statement to simply grab data from multiple tables based on a WHERE clause rather than ON relational matching criteria? I just want to grab rows from several tables by date:…
Convert Sql query to sql CodeIgniter
convert sql query to sql codeigniter i done try to use this method How to convert sql query to codeigniter active records but not working for me… so i try to post in here this my sql query $…
Meaning of this SELECT statement, which does a comparison of two string values
I am reading MySQL in 10 Minutes. On page 63, there is an example that isn’t explained very well. This gives the following result: What is the meaning of the table entry “1”? Does it mean that the value of the expression ‘abc’=’ABC’ is 1? Or does it mean that there is…
MySQL get previous day data
I have the following table What I try to get is writing the day before data on the following day I can get yesterday but don’t know how to do it for all rows. Thanks, Answer You can use next approach. In this query we use join same table to itself by date with 1 day shift. DB Fiddle
Need Help Converting a SQL Query to JPQL
So far, Spring’s JPA repositories have sufficed for me, but now I need a custom query. I have struggled with this for a day trying to learn more about SQL, joins, etc and came up with a native MySQL …
how to get number locate at 2 place before decimal point? [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 1 year ago. Improve this question example: i have a number=143.42 , i want to get “4” which is locate 2 place b…
SQL Join ON clause valid referencing on aliases
I am generating an SQL query and I need to get the data from a JSON stored on a field of my table. It goes something like this So basically I am trying to get put a connection with tables creation and lookup_detail through field FACILITY_DATA which has JSON data and alias of loanType to reference against DETA…
Multiple LIKE Operator ORDER BY Strongest
I have the following query: SELECT * FROM table_name WHERE (genre LIKE ‘%romance%’ OR genre LIKE ‘%comedy%’ OR genre LIKE ‘%horror%’) ORDER BY *the column that has more* OR SOMETHING LIKE …