I have a problem with nextval function, I have a custom sequence in my DB called InternalCodes and when i want to make a insert like this: insert into “Membership” (“Name”, “…
Symmetric Pair in SQL with JOIN
I am trying to find the name of students where a symmetric pair exists. There are 3 tables: Edit from your comment: A student is called as being a part of a symmetric pair if the marks obtained by that student in science is equal to the marks obtained by some other student in mathematics and the marks obtained in
Merge the table based on date and condition
I have following table: In this table type will be 1,2,3,4.. here date and type both are composite key. I need to merge the row based if same date exist to single row and merge based on only below condition and grp col is based on running count of date. Answer Try GROUP BY FIDDLE DEMO Output
SQL query to get data of MCQ question and the answer from two table
MCQ Question and correct answer table name = Table1 Options for every MCQ question and options code table Name = Table2 Table1 Table2 SQL query to get data in the form of – Questions, All 3 options and correct option Answer I am assuming you are using MSSQL as database Use JOINS FIDDLE DEMO Or Output
Assign default values in SQL Server dynamic pivot
Below is pivot query for my requirement. Below is my script for table creation scripts with data. Table_TraineeInfo is candidate registration details table, Table_Batch_Lookup is batch detail when batch start date and end date base on filling in pivot, Table_Attendance_Log is candidate attendance log. My current output I want below output if date is less than or equal to today
SQL Select from multiple tables and count third
I want to count number of rows in table that is referenced by two fields of other tables. I’ve the following structure Result that I want to achieve The statement that I’ve tried, but getting error at right join What I’m missing? Answer You are quite close. Main problems with your query: you are mixing implicit and explicit joins: just
select starting digitals followed by first word in mysql
I have lots of addresses in my database. example: 1199 State Route 218 I want to select the starting digitals followed by first word and ignore the rest of the address. so i want to retrieve address just by calling this: 1199 State thanks for you help Answer If you are running MySQL 8.0, you can use regexp_substr(): Regexp breakdown:
Generate series of random size data in MySQL
I need to populate table with random size of data for each dependency record. First table is table of products (named products): And the second table is table that contains displays of that product (named product_displays). Each display is another row: Like you can see date will always be the same value, but the number of rows that I need
SQL – get specific text from string
I have column with this strings: I need to get from the string ONLY the contact_type__* part (appears only once in each row) Any suggestions? Answer You could use regexp function regexp_extract(), like: This will match on string ‘contact_type__ followed by a sequence of letters, numbers, or underscore (which are commonly defined as word characters).
MYSQL Index strategy when no WHERE Clause
I have this table CREATE TABLE gotrax1.wifi_log ( WifiID int(11) NOT NULL AUTO_INCREMENT, UnitID int(11) DEFAULT NULL, ServerTime timestamp NULL DEFAULT CURRENT_TIMESTAMP (), FileTime …