Im having that problem in this specific line: Probably is a stupid error, but im not seeing a syntax problem here. Answer SELECT city, SUM(credit_limit) AS total_limit FROM table GROUP BY city ORDER BY total_limit WHERE SUM(credit_limit) < 110000;
Tag: mysql
Share price less than certain value for 6 consecutive business days or more in the past month
This is for MySQL 8.X database. My requirement is as follows: If a share price is less than a certain value for 6 consecutive business days or more in the past month then I need to inform the investor. There will not be any share price on holidays and weekends. So there will not be any data for these days.
How to insert values for the current session user using $stmt = $connect->prepare
This is my current code for adding some additional information to a database table named klantinfo. This information is added after the user is logged in. At the login, the given username gets inserted into the login table, but also into the klantinfo table. This way I can compare the username in the database…
Migrating from sql to mysql
I want to transfer a database that I created with sql server with the information in mysqle. An example sql file is as follows No connection to the database should be interrupted during this migration. SQL File Answer Given the length of the script, it would be best to you use an online converter. A good choi…
Calculate percentage on an MySQL query
I have a query that returns some counts of data as follows, basically this table is posts and will contain either inbound or outbound posts. I want to make a query that will return the percentage of outbound posts. e.g This returns something like the following… How would I modify the query above so it r…
MySQL Multiple Conditions in Grouped Data
I am trying to see how many users have clicked on an ad campaign and signed up afterwards. My Logging table has the columns IP, UserID, and Data (this has the $_GET info like utm_source = newsletter). A user may click a link in newsletter and then later sign up on my website (which is indicated when they have…
MySQL customized exists query performance
Because of using Hibernate, I cannot write a JPA query using exists like this (I translated it to pure SQL query): So I have to write an alternative query to check existance of activated accounts. After reading several suggestions on this website, I see a replacement: My question is: Is this bad for performan…
How to sum the values of two columns and have it in a new one? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 months ago. Improve this question I’m trying to sum the values of two columns into a new one, its for analysis purpose …
Is it possible to omit FieldID in struct when using gorm?
Looking at an example from their documentation: CompanyID field seems rather redundant. Is it possible to get rid of it using some tags on Company field instead? Answer Changing User definition like this did the trick:
SELECT rows with MAX id minus 1 with group by
I have a table with id, city_id, and stock which looks like this. id city_id stock 1 1 1000 2 2 500 3 3 11000 4 2 600 5 3 12000 6 1 2000 9 3 13000 10 1 3000 11 1 4000 12 2 700 To select the latest stock values for each city_id I used the following query,