Suppose, I have a table tblClasses and tblStudents Now each class have multiple student. tblStudents now, I have another server having exact same db and tables and I am copying data from server 1 to server 2 from same tables using the Select and Insert e.g. and for tblStudents now this is ok but the real prob…
Tag: sql
Rows that are in table A but not in B
How can I check the rows for columns a, b, c, and d in table A but not in table B? Answer If you want to get full rows from table a you can use exists:
How do I translate this specifik SQL statement to LINQ
SQL: C# Objects: Monitor: And Counter: And the objects that I need to turn it into is: AllStatistics: I don’t have much experience with LINQ so the most I’ve achieved with it is somethig like: My question is, how would I compose an LINQ statement with the same functionality of the above SQL query …
Table data show one by one record different two tables?
Table 1 ABC DEF GS PM BS PK Table 2 ABC DEF YZ TT UG KK Need output ABC DEF GS PM YZ TT BS PK UG KK So please help me sql query Answer table1: Azbuka Def A1 D1 A2 D2 A3 D3 A4 D4 table2: Azbuka Def F1 H1 F2 H2 F3 H3 F4 H4 Result: Azbuka Def
SQL query to CONCAT/list unique column data if rows have identical data in the other columns?
Thanks in advance. I’m basically trying to run a SQL query so that the results are 1:1:1:1:Many for StaffID:Name:Floor:Date:Shifts. Here is my initial query and example results: I then combined the ShiftStart and ShiftEnd columns with the following to get the further below results: What I can’t fi…
Get value for every date in table with date ranges
I’m working with table, its structure looks like this: from_date DATE %Y-%m-%d to_date DATE %Y-%m-%d person VARCHAR tax INT Table shows that in period between date_from and date_to for such person there was such tax The whole point is that these periods can intersect and activities can sum. Roughly spea…
SQL GROUP BY IN CASE STATEMENT
i have one table i would like to classify the apple as below i try to add code as below, but its not like what I expected I try this code also, but got error Answer You want conditional aggregation here, which involves summing over the CASE expression:
Failed to add the foreign key constraint. Missing index for constraint ‘information_ibfk_1’ in the referenced table ‘informacia’
What is the problem with these tables? I want to create foreign key for second one Answer In order for a table to add a foreign key constraint, the referenced column (zip_code in this case) must be a PRIMARY KEY or must have a UNIQUE constraint (ideally with NOT NULL). I modified the SQL statements according …
Junction table in PostgreSQL
I have two tables I created a junction table called “recipes_ingredients” My first question is: is it correct how I created the “recipes_ingredients” table? Do I need the “id” or I can just have the two foreign keys “fk_recipe” and “fk_ingredient”? A…
SQL: Grouping Paired Rows Without Field to Aggregate On
So say I have the following: Timestamp Event_Name 10:47:00 RESUME 10:37:52 SUSPEND 10:26:20 RESUME 09:48:27 SUSPEND 09:39:13 RESUME 09:15:38 SUSPEND 09:11:42 RESUME I want to be able to pair them as such: Suspend Resume null 10:47:00 10:37:52 10:26:20 09:48:27 09:39:13 09:15:38 09:11:42 If each pair had anoth…