I have written this scalar function in TSQL: create function TCupom (@cupom int) returns float as begin declare @Tcu float; select @Tcu = sum (total) from alteraca2 where pedido = @cupom …
python – how to check if table exists?
I’m using this function : def checker(name,s) MY_T = “SELECT count(*) FROM `”+session.SessionInfo.Name where EventName=’”+name+”‘” I want to check if the table exists, how can I do it ? I …
Select row with most recent date per user
I have a table (“lms_attendance”) of users’ check-in and out times that looks like this: I’m trying to create a view of this table that would output only the most recent record per user id, while giving me the “in” or “out” value, so something like: I’m pr…
Change values before insert into table / PostgreSQL
Ive got the following problem. I want to change some values of INSERT statement, e.g. there’s a query: INSERT INTO table(a,b) values(x,y); But table has also another column c. I want to check (…
mongoDB vs mySQL — why one is better than another in some aspects [closed]
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, …
Formatting bigdecimals sql oracle
To have a readable big numbers under oracle and to facilatet the reading, I’m looking for a way to add blank space to obtain something like that: 213537592384.236 ===> 213 537 592 384.236 The problem that I have big numbers like above. Answer Spaces are a curious separator, and not directly supported…
effective innodb_lock_wait_timeout value check
I have a table with lakhs of rows. Now, suddenly I need to create a varchar column index. Also, I need to perform some operations using that column. But its giving innodb_lock_wait_timeout exceeded …
Get row with highest or lowest value from a GROUP BY
I’m trying to get the row with the highest/lowest number, after performing a GROUP BY: Here is my test data mysql> SELECT * FROM test; +—-+——-+——+ | id | value | name | +—-+——-+—…
ORACLE ALIAS in WHERE Clause Subquery
Here is my SQL code. I used subquery and labeled it, but when I call column from that subquery, it shows that as invalid identifier. error as per below Please help me to sort out this issue. I need to call subquery’s columns also in my final SQL view. Answer You can only use colums that are in your FROM
SAS datastep/SQL select latest record from multiple records with same ID
For example I have a dataset as below: By datastep or sql, how could I get the record with id = 1 and latest Date 2002/01/01? Help is appreciated and thanks in advance. Answer Try this sql.