I have some number like These numbers are only an example I have a lot of 14… a lot of 15… etc. Now in WHERE clause of a stored procedure, I want to exclude all numbers who start with 15 or less so I can do something like: Is there a way to change this and use something like TestColumn
SQL GROUP BY where partitions meet condition
Consider following table: I want to group by var_a in such a way, that each group would have in it var_b = ‘123’ and var_b = ‘456’. That is, I want to obtain “abcd” and “ijkl” in the set of results. How do I do that? Answer You can filter the table and group by …
getting number of columns and rows in my tables
How to get the number of columns and rows for each of my tables in oracle? So far I know how to display the number of columns for each table: Answer
Select everything from SQL database except duplicate
I have a database that looks like this: It measures how many times participant1 and participant2 have shaked hands. I want to select the amount of times total people have shaken hands (without the duplicates counted). So in this example the output would be like this: Can anyone help me with the SQL Statement …
SQL IF statements in transactions
I’m trying to make a condition where if the number of available seats within a given plane is less than zero then ROLLBACK. However, I am receiving a message stating that there is a syntax error at IF (i.e. “syntax error at or near “IF””). Why is this, can I not use if statements…
SQL – Like and wildcard, not expected result
I’m still a newbie with SQL so please be patient with me. I have got the following WHERE statement in a query: It’s producing the following result (as expected): While if I remove the ending wildcard, like this: It results in an empty table. What I cannot understand is that the city name “Re…
Create a combined primary key with a one column accepting NULL
I have a table CustomerLocation with the following columns : Country Region City I want to create a composite primary key with the 3 columns mentioned above knowing that the Region column is NULLABLE. Answer You can’t. The definition of primary key specifies that only non-NULL values are allowed. This i…
SQL query is causing problem while inserting into table
I tried to insert dataframe using pymysql library. It’s giving this error: pymysql.err.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”bestwebsites’ (‘Rank’,R…
Was column ever equal to x in sql
I have a dataset that looks similar to this: I want to check if the description was ever equal to X, grouped by unique ref. I would also like it to have a separate column for the date in which description was X. If the unique ref has been X more than once then the date would be the most
MySQL find column name where it’s value match the pattern
How to search the entire database for column name equal to my rule and specific value as well. Let’s say that i want to search for column name like voucher where it’s value contain that word value10 So far i can find the column name but i don’t know how to match with value as well. So the en…