Skip to content
Advertisement

sql get balance at end of year

I have a transactions table for a single year with the amount indicating the debit transaction if the value is negative or credit transaction values are positive. Now in a given month if the number of debit records is less than 3 or if the sum of debits for a month is less than 100 then I want to charge

Override query in sql string possible? C#

Currently I’m working with my local MSSQL database and when I make a connection all works good. However that is not the question I’m having right now; I want to make my code cleaner and I don’t want to have duplicated code or almost duplicated code. For now I’m working with one large class that holds all the methods to

Join multiple columns from the same table using Linq

I would like to convert following sql query into Linq to SQL going through this I have so far tried following which didn’t work out Edit: following query is being generated against Svyatoslav Danyliv answer which is returning 7 rows instead of 6 Answer Join which contains not just AND expressions is possible via from x in entities.Where(x => ..).

Ranking in SQL Server with a column change

Below is the original table that I want to rank according to the column changes by Install_Status and Dates for each product. Query: This SQL query returns the following results: However, I am not getting appropriate ranking for product A by date. My expected result is as below: Answer You seem to want to count the changes. For this use

Using CASE with Table Join

I am using Oracle 11g. I have two tables: I want to display student_name, course, fee and a column with discounted fee where the fee is reduced by 10% if it is either ‘BIT’ or ‘MIT’. I’ve come up with following query but it gives an error: ORA-00923: FROM keyword not found where expected: Answer You can use decode as

how to select set of records is ID is present in one of them

Here is the table where ORGID/USERID makes unique combination: I need to select all records (organizations and users) wherever USERID 1 is present. So USERID=1 is present in ORGID 1 and 2 so then select all users for these organizations including user 1 itself, i.e. Is it possible to do it with one SQL query rather than SELECT *.. WHERE

Advertisement