Skip to content
Advertisement

Tag: database

SQL Query Sequential Month Logins

I have the following SQL table username Month 292 10 123 12 123 1 123 2 123 4 345 6 345 7 I want to query it, to get each username’s login streak in Count of sequential Month. meaning the end result I am looking for looks like this : username Streak 292 1 123 3 345 2 How can

Trouble dealing with max() function in SQL Server

The whole code is part of a stored procedure. I have two pieces of code: This one works fine. On the line this particular code is producing the output: and the other one: This is not working correctly. I get an error: Subquery returned more than 1 value on this line Independently it produces this output: Column and table names

Find rows that have the same value and select the newer one

I got a table, that looks like this: serialNr sensorNr ModifyDate 1234 12EE56423 2022-04-06 4567 12EE56423 2018-06-12 6789 AD3FF0C44 2018-03-08 9101 AD3FF0C44 2019-06-07 From rows with the same sensorNr, I only want to select those with newer ModifyDate, so the result should look like this: serialNr sensorNr ModifyDate 1234 12EE56423 2022-04-06 9101 AD3FF0C44 2019-06-07 How can I achieve that? Answer

Search in the database

This Messages form display table with these informations (ID,FROM,TO,TITLE,MESSAGE). I am trying to search for all the messages send to a certain user . user will enter his name in the Search_textBox then it will filter the table to keep only messages to this user. I get this error : Answer this is Correct

can’t set a foreign key on oracle sql

Here is my code: and it gave me this error: What is wrong with parenthesis in my code? this only happens when i set foreign key. Note: i am using SQL cmd from Oracle Database 11g Express Edition. I’ve tried making theses tables on MySQL and it worked fine. Answer No “FOREIGN KEY” keyword is used for inline constraints. So,

Advertisement