Skip to content

Tag: sql

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.

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

SQL Count In Range

How could I count data in range which could be configured Something like this, Table ZONE_CFG is configurable, so I could not use static value for this The DATE column mean maximum date for each ZONE And the result what I expected : Please could someone help me with this Answer You can use LAG and group by as…

What am I doing wrong in this where statement?

I’m using the following logic in my where statement. If I do just the statement below then it returns results However if I expand on the where logic to the following statement it returns no results. Why? Shouldn’t it return the same thing as where statement above? Basically what I want is the foll…