i have written a query which returns a table showing monthly total working hours of each person in the company. so the result is: name*****jan************feb**********march ……… dec Tom 170:…
Tag: sql
How to order the query result based on following condition?
Let’s suppose I have a table as below: employee | period | commission A | 1Y | 100 A | 2Y | 150 B | 1Y | 80 C | 1Y | 200 C | 2Y | 270 C …
SQL Server: remove duplicates in exchangeable columns
I have this query: select OSFES97.CodeId, OSFBA97.CodeId, OSFES97.ReceiveDate from StockArchives OSFES97 inner join StockArchives OSFBA97 on OSFBA97.ReceiveDate = OSFES97.ReceiveDate …
Value referenced by NEW on an unchanged column in an UPDATE trigger
I have a table Group_Members with a DELETE trigger and an UPDATE trigger. The DELETE trigger updates some rows in A hence invoking the UPDATE trigger. Here’s the DELETE trigger code: UPDATE …
Find Interest rate on account statement in sql
i hava table of statement and it has the date,credit,debit and balance column through these i want to find total interest. TRX_DATE CREDIT DEBIT BAL ——– ———- ———- —-…
MYSQL query for first 40 records and else records
I have a table names ‘tbl_featured_professional’ where fields are: id, user_id, ranking and score, createdDate What I want is first 40 records are ordered from ranking (which is unique) and all …
How to create a constraint for conditional unique values?
I am using SQL Server. I have this table: CREATE TABLE Student ( ID int PRIMARY KEY, FirstName varchar(100), LastName varchar(100), Active bit; ) I want to have unique(FirstName, …
If else using case for returning value
I am trying to do an if else statement using CASE. If no records, then make it 0 then +1. Or else, just take the last record then +1. At first try i used ISNULL(statement,0). But it doesn’t have else …
How to select rows from table where group does not contain value
I have a table that contains the following fields: Thedate,Thetime,Course,OR,L1R,L2R,L3R I would like to only return values if a group (Thetime) does not contain the value “0” in L3Ra column. I …
Multiple CTE where clauses referece CTW column
For example WITH UserDetail (UserId, UserName) AS ( SELECT TOP(10) U.UserId,U.UserName FROM UserTable U ), UserAction (ActionName,ActionType) AS ( SELECT TOP(10) A.ActionName,A….