I want to retrieve a record where the age group is greater than 50 and show the top 2 month. As we can see in the age_group there is 2 row fall in month ‘3’. The total value in month ‘3’ is 28. And the another month which have the greater value is month ‘4’ Answer You must group by
Tag: sql
right way to get sum of all the counts done in sql
This is my query, I want to get how many numbers of phones call received today as one column, so how do I do a sum using count function? If I do a sum, that would just return the total sum? how do I return the total numbers of all calls received today, I would do count uniquecallerID and then
How to update status for part with nothing data when this part is missed?
I work with SQL Server 2012 and have an issue: I can’t update status with No data returned where no result returned from select statement cross apply function. Meaning where no data returned when join parts and company to function then update status to this part with nothing data for that part when data is missing. When I run a
Compare two MYSQL tables and return missing dates and group by column
I have two tables. I want to compare table A with B and get the missing date from with name of the user. TABLE A TABLE B EXPECTED OUTPUT Also, Along with it can I get the count of the missing dates for each user if possible? Answer You must cross join Table B to the distinct names of Table
Cross Join in Hive
I’m trying to create a new column time_period while running the query below. If the date difference between a given transaction and the most recent transaction in the reference table is fewer than 7 days, then mark it as a recent transaction, else mark it as an old transaction. However, the query below is generating an error in the subquery
Select every second record then determine earliest date
I have table that looks like the following I have to select every second record per PatientID that would give the following result (my last query returns this result) I then have to select the record with the oldest date which would be the following (this is the end result I want) What I have done so far: I have
Django: How to mangle through relations
I have an instance of ModelA and want to query all instances of ModelC which are related to ModelA through ModelB. ModelA -> all ModelB instances with FK rel_a = ModelA -> rel_c.all() I know how I would do this in SQL but I really do not get how I should unmangle these relations Answer You can query with a
SQL query with having function to only includes parts of another column?
I am trying to find fact_order_id’s that have beverage only items. This would make the fact_order_id not include any food items. I have used 2 separate SQL Queries below. When I go back and check my work, I notice some fact_order_id’s in the output aren’t beverage only orders. Here are the 2 separate SQL Queries that give me the same
Pass data from PHP to HTML
Edit: Thank you for your help and time. I will change all my extension to .php as recommended and check the link that was shared :)! I’m a beginner at coding and I have been stuck for a few days on a problem. So, I have coded a html page with a login form. Once the user click the button
How do I remove duplicate data in SQL?
I need to display lines that are not repeated, but only with their neighbors, they should remain in the entire database (also in a single copy) in sqlite. Here’s what I’m missing: Initial database: What should be output: Thanks 🙂 Answer Using Lag and Case: