Table StructureWrite a query to display the total month wise sales amount received in the past 1 year . Display details like sales month, total sales amount. Give an alias_name as MONTH for retrieved sales month, TURN_OVER for sales amount. Sort the result by amount in descending order. (Hint: Use table Sales…
R : x comparison (1) is possible only for atomic and list types
I am using R. In a previous post (R: Loop Producing the Following Error: Argument 1 must have names), I learned how to make a function (“create_data”) for my code. Now, I am trying to modify this function. First, I create some data to be used for this example: Here is the modified version of the f…
Find two values of one Column based on value of another column per ID
I have a sqlite db with one table that called Loan. This table with sample data is here: Loan Table at sqlfiddle.com This table contains below Columns: Now, I need a query to show desired result, contain [empid],[Codepayid],[Lval-1],[Lval-2],[Sum(Lint)],[Lrmn-1],[Lrmn-2], With this Conditions: For example: Re…
MYSQL Trigger not adding count after inserting rows into another table
This is a continuation of this question: Insert data into a table with a foreign key SQL I need to create a trigger that updates a counter variable after I insert a row into a table. The counter variable keeps track of how many new rows are inserted into the ItemBook table. However, after running the script, …
Sorting behavior specification in order by for window function in GBQ
I am running a query in GBQ using window function. but I don’t exactly know how to specify sorting behavior. In order by column I have two columns which I want to sort rows by them in descending order….
Assign same group number for N-members in SQL Oracle
let’s say I have only one column of different codes, for example Code A B . . . Z I need to add new column with group number and I need it to be dynamic that means sometime I need 10 member group …
Android/sqlite – ContentResolver query with user input
Currently, I’m using this method to query all photos user’s phone has: I wanted to allow the user to filter the query by file names, so I added selection & selectionArgs part. (getSelectionArgs() returns “” if there is no user input. It returns the input if there is.) This method h…
LIKE clause in T-SQL statement does not return value if compared with a variable?
I am trying to find all the backup tables I have just created with another script. declare @bkup_tbls varchar(20) = ”’%_’ + LTRIM(RTRIM(CONVERT(CHAR(8), GETDATE(), 112 ))) + ”” select @bkup_tbls …
Deleting records in MySQL WHERE id IN (@VARIABLE) — (2,3,4)
Is there is a way to delete records using WHERE IN @VARIABLE? Create variable: I’m trying to remove concatenated variables from string. The above SQL removes only first element from the list. In this example, list will contain: (2,3,4). Only the record with id = 2 will be removed. Records with id 3, 4 w…
Query end of week and end of month data
In an Access database, if I have some stock data that is in the format of DateFormatted DateSeconds CodeName Close 2000-01-01 946684800 AAA 1.01 2000-…