Skip to content

Repeating rows but changing column value each time

I’ve this table with the following data: ID  Quantity Status 1    250      OK   2    440      HOLD 3    180      HOLD 4    860      OK Based on the value in the Quantity column for each row, the row should be repeated again if Quantity is bigger than 200, but repeated

SQL GROUP BY and COUNT with multiple columns

I know I’m just making a simple error somewhere, but I can’t figure it out. I’m sure this is beyond easy. I have a table with user ids, names, and a profile. I’m trying to count the number of users with each profile, and group them by the profile. Below is a sample of fake data. This i…

MySQL keyword aliases

I would like to set up aliases for MySQL keywords for faster typing of repetitive (or any, really) queries. Example: -> becomes: How could I go about achieving the above? I have looked around but unfortunately, most searches point to column and table aliases and I did not see a mention in MySQL documentati…

MySQL sort by 4 fields date and time

I have a table where there are 2 date columns and 2 time columns (arrival date, arrival time, departure date, departure time) I want to combine the 2 date fields in one and then sort by date, arrival …