Possibly a dumb question because I’m totally new to SQL (I mean never touched it before today ????) but I’m adjusting a report in a program we use, so it always gets values for the year ending last …
Why am I able to call the class method as if it were an instance method here?
I was looking through this example: class SQLObject def self.columns return @columns if @columns columns = DBConnection.execute2(
single or multiple search with a single query based on condition
For example i have this table component_information with these atrribute I will pass the group_code,category_code,compnent_code from the frontend for searching.Now i want to do single or multiple search based on this. Like on first condition if it gets only group_code value from frontend it will do search onl…
Select Top N rows plus another Select based on previous result
I am quite new to SQL. I have a MS SQL DB where I would like to fetch the top 3 rows with datetime above a specific input PLUS get all the rows where the datetime value is equal to the last row of …
columnA like %columnB
I’m trying to do select * where column1 = % column2 %. this is my query The error: The data types varchar and text are incompatible in the add operator. Answer You can cast the text to a varchar(max): Or, if b.Client is a text too: Notes (most of which already were commented): text is deprecated; you wa…
format date in oracle SQL
I was trying to learn how to format date in oracle pl oracle, when I ran below query its returns error Answer for my scenario I had to use to_char which perfectly solve the formatting issue.
Java + Postgresql : How to store Parent and List of all children in a HashMap>
I have an sql table Children : | ParentName | ChildrenName | ——————————————————————————— | parent 1 | child 1 | | parent 1 | child 2 | | parent 2 | child 3 | | parent 1 | …
Loop and insert more than one comma separated List in SQL
I wish to loop through two comma-separated values and perform an insert As an example lets consider two variables Using this loop I am able to extract @Answers and can perform insert. But I wish to extract @Qid and insert inside the loop. edit for more clarity it is a feedback module. my result table have Qid…
Sum By Criteria in specific column
I have questions about SQL Server query for SUM. I have 2 tables: 1) EmployeesAtt (EId, EName, Stats) -> I have some criteria for Stats (0 = late, 1 = overtime, 2 = normal) 2) AttLogs (ID, EId, late, overtime, normal) From EmployeesAtt table, I want to SUM the EId And Stats in dedicated column in AttLogs l…
changing sql statement to eloquent query
So I have an SQL statement as such; How do I change this to an eloquent query? Or is it better to just use a db:raw query? All inputs are very much appreciated. Cheers! Answer You can try this : Read more at whereBetween section in here