My table looks like this: Product Length Width Height A 34 22 10 B 40 2 12 I would like to get the longest, second longest and third longest side for each product. For the longest and third longest it was easy, I did it like with GREATEST() and LEAST(). For the second longest for the moment I am doing
Tag: sql
Using group by with order in postgresql
Query: It yields this: What I need is to show those “fightEventId”s that have more than 2 CONFIRMED fights. Currently all records are ordered in the right way, so the result I expect is: How do I do this? Every time I try, I get errors or the order is broken. As for the DBMS used in the project, i…
Android Room Query returning null
I am trying to get the values from a DB via Room but it always returns null. It should retrieve the data from DB BalancesCat. Any help? Thanks! This is the DAO Repository ViewModel and the Fragment where I want to retrieve the data Answer This isn’t your problem, but I have to mention, your repository&#…
select data from range of two dates
I want a query for selecting data between two dates (p_startdt,p_enddt) which is given by the user, if there is no input then by default data of last one year will be given as output. I am not able to put case for null or no input Answer Use NVL to handle the case of a NULL value. The following
How to not retrieve duplicate row due to stored procedure
I’ve been using my stored procedure to retrieve events filter by : a date start, a date end, a shopId, a sellerId and customerId. First of all, here the principal structure of my database which causes me the problem : Ticket: Id Reference .. .. 15222 BOOKING56654 .. .. Seller : Id Name .. .. 41 Caty .. …
How to write Criteria Query that checks for multiple values in same column along with other WHERE conditions?
Please convert the following SQL Query to a Criteria Query——— I have the following table PEOPLE- ID Name Code 1 Tom A 2 Harry B 3 Tom C 4 John A 5 Sally C 6 Tom B 7 Tom D The query must return the list of records that satisfies the conditions- Name=’Tom’ AND Code=’A’ …
SQL Filter by dateTime
day is a integer variable. If I set the day value to 1, database is filtering for 24 hours. But if I set the day value to 1, I only want to see the logs of the new day. How can I do that? Thank you for your help. Answer
Avoid unnecessary update in “update or insert” SQL?
Here is Firebird SQL description for update or insert: https://firebirdsql.org/refdocs/langrefupd25-update-or-insert.html And my example If book already exists with id=555 and name=’Good book’ then this command executes update statement anyway and the triggering of update triggers is the only effe…
how to copy values from a column to a non-existent column in postgresql
i have a table like this: and i want to copy the values from the first column to the non existent column that is ‘qty’ how do i do that if they have different data type? what i originally wanted is when the 1st column’s value is 0, then the column qty should be blank or empty, not [null], i
How does a Laravel model get a “required” data? New column, adding another column’s data
Still new to laravel, learning how the $request interacts with create. here is my form for two of my variables for context: controller: model: my title and category_description is inserting fine with an auto incremented id column. What I am trying to do is just to add 2 columns: category_id and category_descr…