I have a query that selects 3 columns. Each row row should be a unique combination of county, city,and zip. However, I have reason to believe I’m getting a duplicate somewhere. How do I find the …
Tag: database
Is there any pros to not using Many-to-Many relationship [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago. Improve this question I have been asked to create a small program for assignment based on given instructions. I was given two tables I
INSERT SELECT statement with only one column for SELECT
I’m using SQL Server Management Studio 18 and I’ve got the following tables with the following columns: TableA TableB I want to do an INSERT SELECT into TableB, maybe something like the following: Basically, I just want to make an INSERT SELECT where I’m grabbing a column from another table (InternalEmplID), and then for the other columns (Month and Year),
SQL – Matching only the values in IN clause (not less or more)
I am having the following ManyToMany table TEAM_USERS with the below data: So, I want to get the TEAM_ID that is having only two user with the USER_ID IN (3, 4), in this case it’s team 11. But I am getting team 1, 11, and 12. And I want only team 11. I did the following code but I am
Check datatype of column after applying function MySQL
I want to know datatype of column after using a function. After using timediff function what datatype is it? I’ve looked at the doc to search for output datatype of a function https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html but could not find, Also it would be inefficient to memorize which function outputs what datatype, so I would like to perform an operation creating new column
Double quotes problems with Postgres
I am using Django with postgres. Here’s the snippet of my code which I am using to create tables in the db. My question is: why is the user table getting renamed as “user” (with quotes) why is the role_id getting named as role_id_id where as I have clearly mentioned role_id to be my column name? Answer After reading few
Oracle “NOT IN” not returning correct result?
I’m comparing two tables that share unique values between each other using NOT IN function in Oracle but I’m getting the output is: 521254 for all charging ids –< this is the total unique charging ID’s in BILLINGDB201908 Now I want to find id’s in table BILLINGDB201908 that also exist in table CBS_CHRG_ID_AUG — the result back315567 charging ID exist
Remove duplicate values by taking latest data load
I’m working with enterprise data that looks like this. The issue is that the company has bad data practices and changes/reuses IDs, but only updates the load_number field. How do I construct my sql query to pull the latest loaded data like so: Basically every field will match except the id and the load_number. So given that every field matches
How to deal with fixed max number of posts a user can make within a time period?
Sorry for titlegore. Users can have at most 3 active posts, and each post is active for 48 hours. I was thinking about just putting active_post_{1/2/3}_id and active_post_{1/2/3}_expires_at on the users table, but wondering if there is a better way to handle something like this. Answer I would store only the timestamp of the post and use middle-tier logic to
I have to get the total time spent for a question using SQL. I am unable to get the total time and provide the answer in minutes or H:M:S format
I am trying to find the total time taken per person and provide the answer in total minutes spent using SQL. The page_start_time is time data type.The data is shown below: This is the visitors table. I need to find the total time taken using the page_start_time field per USER_ID. I tried the following code: I got the following answer: