I have the following query that is grabbing data from a table and combining all the products into one column and counting the quantity of that order. I need to add an additional column to the output though, how can I also add ship_date? This is how the original table is laid out: And this is how the query out…
Tag: mysql
Query to find people with multiple names
I’m working on a fairly big project that allows users of my client’s site to search for people they used to know who might’ve changed their names, primarily due to marriage. Basically, users sign up with all the names they’ve ever used and the data gets entered into a MySQL database. T…
How to create a MySQL 5.6 Rank with JOIN and multiple sorting criteria
I am stuck trying to return the rank of an SQL query. The final row should show the rank of the sorting that is presented correctly. I should be seeing Rank = 1,2,3 but I get this instead … I’ve tried numerous variations of the SQL statement but I cannot strike on the solution. Ideally, I would us…
SQL Query with Group , Order by and Random at the same time
I was unable to find anything similar to this problem. As we see John and David has more than one row and there’s a Order column so we can order it simply using ORDER BY Name ASC, Order ASC but this is not exactly what i need.. Here is the problem: i would like to know if its possible to
My SUM query returns 2 rows, need some advise
I am getting 2 rows(9500) for 111 in the result, could you please advise on the right approach, I need like, Balance = (sum of bought – sum of sold) Query Answer You can use conditional aggregation: If you want this for only one account, you can add a where clause:
How to find records within a certain timeframe based on another field
How do I find all records 7 days before a field in an SQL database? I need to find all transaction dates that were placed 7 days before the pickup date of the same record. I am currently using SequelPro so that my have an effect on available syntaxes. This is currently my table that I am pulling the records
INT type in SQL max value calculation
I am currently learning SQL. When looking at the INT, I came to the understanding that an INT type is 4 bytes long, which translates to 8 bits each byte, leading to each INT being 32 bits. However, for INT it is said that the max value for unsigned types is (2^32)-1 where the -1 is accounting for 0 value.
Find record that the least amount appears in MySql
I have 2 tables Booked Books I’m currently working on this query but the result is not correct. Output The result that i want is Can you help me to fix it? Thanks. Sorry for my bad english Answer Your question lacks the clarity but to my instinct of what you have posted may be this will work, as far
Match duplicate value from the second column based on duplicate value from first colum
I have table like this I have two condition for this table which is : Val column must be duplicate value AND, Val2 column must be duplicate so my goal is return data if the two condition meet. If the column val had duplicate value and column val2 had duplicate value and each column on his own row. my query
How to read JSON value in MySQL
The JSON output I need to insert into my database but my source code throws an error: The source code: Can anyone help me with this, as I need to get values for open, close, high and low. error: Answer you have 5 columns, hence 5 bind variables. Your insert template is over complicated with any database opera…