Is this a possible query? Currently, every product from my database is being listed on the home page of my website and a lot of them are duplicates since a product can belong to multiple categories. I am using “SELECT * FROM Books WHERE product_status = ‘1’”; Answer Then use group by a…
Tag: sql
How do I do SQL sum across a table diagonally?
I have this table: I want to get this: The idea is to sum up the Col B of Quarter 1 with Col C of Quarter 2… and group by Col A Answer Very strange, but you can use conditional aggregation:
CUSTOMER and purchased CATEGORY count details in Oracle SQL
I am having the below require. if anyone provide the solution it would be thankful Requirements:- Transaction of the customer who purchased in the below category Customers and purchased Category Total Number of customer from category level category and customer count I want to display the output life below ou…
How to convert list of comma separated Ids into their name?
I have a table that contains: I have the table that has the names of this tasks: I want to generate the following output I know this structure isn’t ideal but this is legacy table which I will not change now. Is there easy way to get the output ? I’m using Presto but I think this can be solved
Create query to get count of uncompleted calls
There is table waiter_log as Call with call-id ‘f27de4f’ started in 9010 and finished in 9003 because there is a record with proceed_wait = 0 for call-id=’f27de4f’ Call with call-id ‘asdf231′ started in 9010, still proceed in 9002 and not finished yet because there is no re…
Script timeout passed error on MAMP phpmyadmin
I’m trying to upload this sql file that’s 225MB to phpmyadmin with MAMP. However, I keep getting this error Script timeout passed, if you want to finish import, please resubmit the same file and import will resume. I’ve changed the php.ini file in MAMP like so: I’ve also changed the se…
MySQL check two columns for value but with a preferred column result
I have a MariaDB SQL table, with two different ID rows. Id’s have been imported from a previous DB version (old_id reference is from another table), as a transitional measure searches need to be done to find id’s, with a preference for the older id value. Only ONE row can ever be returned . Table:…
How to remove ‘wasted rows’ after delete in Oracle SQL database
In Oracle sql database, a process in our system deleted (not truncated) approx 2 million rows from a table. This resulted in a huge number of ‘wasted rows’ causing the queries running on that table to take more than 9 hours which usually get over in 5 minutes. Upon checking, we found that the size…
SQL – Getting duplicate list based on value from multiple column
First, sorry if the title is misleading, so i make this example. Table : data_list Column : Serial, A1, A2, A3, A4, A5 Datas : 381, 0, 0, 0, 125, 99 537, 10002, 1234, 0, 0, 0 931, 0, 0, 0, 0, 0 1213, 123, 100, 0, 0, 10002 1437, 7361, 918, 17823, 0, 0 7777, 0, 0, 100, 0,
Select sum if and having count
I have 3 tables table artist with artist_id, name; table album with album_id, artist_id, name; table songs with song_id, artist_id, album_id, (few more things but I don’t think they are necessary for this problem); I want to select a table with the name of the artist, number of albums with equal or more…