I am trying to select all usernames that have a at least one windows operating system. Some users have many windows operating systems, but I really only need to know if they have at least one. I know DISTINCT can filter out duplicates, but the issue is these rows are unique, if they have more than one OS. For…
Tag: sql
Where clause with multi AND & OR conditions
I got a table agenda in which the admin can make a reservation for him self or for someone else (another user). If the admin make the reservation for him self in agenda.user_id will be stored the id of admin. In case that admin make a reservation for another person (another user) in agenda.user_id will be sto…
Is it better to pivot data in SQL or in my application code?
I have a very long & narrow table in a MSSQL Database, one that looks a bit like: date dataItemName dataItemValue 2021-01-01 Units Sold 20 2021-01-01 # Customers 2948 2021-01-01 ARP 19 2021-01-02 Units Sold 146 2021-01-02 # Customers 157 2021-01-02 ARP 32 And I’m trying to get a table of the form: d…
Extracting data from only the year
I have data in a table in SQL with dates, but how do I select only those that happen in 2021. (The dates look like 31-oct-2020) in the table. The dates are the actual date variable, not just text. Answer You should avoid storing your dates as text, but rather should use a proper date column. That being said, …
Find sum from 2 tables and write code in php [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago. Improve this question This is the query image: This result should appear as follows: This is m…
MySQL Update inner Join with MAX Date
In MYSQL 8.0 I have two tables with following structure: I am trying to update a value of EnromentStatus in child table by joining in on Enrolment table using the TSQL below: Problem is Enrolment has multiple entries for the child enrolment so I need to do MAX(DateUpdated) to get just a single record to updat…
Output records with null values even if not present
I have a table as below in Oracle gen_id serial_code is_verified 1 fmcg Y 1 smcg Y 1 xmcg N 2 smcg Y 2 fmcg Y 2 2mcg Y 3 smcg Y 3 amcg Y Now I want the output for max gen_id which is 3 in this case and serial_code ‘smcg’ and ‘fmcg’ I can get the output easily
SQL Generate per day records between dates
I have a table that where each record has start and end dates. I need to return a record for each day between start and end date fields (including the start and end dates). Using MS SQL Server. Example: Current data Data required: Looking for recommendations. Thanks. Answer You can use recursive cte :
Inputting data into a table from two different tables
I have these 3 tables with data and then created a third table that looks like this I want to populate my new table with the Subjects who were involved in projects that were lead by Dawn Elgar (PID is 10001). Is there a way to do that across 3 tables? I am close with code that looks like this
R: “Fuzzy Match” and “Between” Statements
I am working with the R Programming Language. I have the following tables (note: all variables appear as “Factors”): I am trying to “join” (e.g. inner join) this tables on the following conditions: 1) if table_1$id “fuzzy equal” table_2$id AND 2) if table_1$date BETWEEN(tab…