How can i order the results in my select query to have them like this? I tried this query but the result is not what I’m looking for: In which col1 represents the first number, col2 is the second one and col3 is the last number in the above example. This query returns: Thanks Answer Sort should be 1-3-2, I’d
Tag: select
Getting values based on other column
I have the following data in SQL. Is there a way using SELECT QUERY that we can replace the NULL values in DATE column based on the REF values? Like replace the NULL values with the first available date for matching REF value, without making any change to the database. Expected Result Answer You can do it with MAX() window
SQL Insert into with join and where
I have three tables. For example: newTable: oldTable: associativeTable: What I want to do now is: I want to move the name column from oldTable to newTable. I have already altered newTable and added an empty name column. Now I’m trying to write a correct INSERT INTO statement. What I have so far is: I’m a bit lost on it.
Use column references in Oracle SQL select query to avoid re-calculation
I want to create a summarised database backup report, which includes data from multiple database tables which has no relation to each other. For example, I want to include the name of the database from v$database view: And the size of the database: And consider there is no common column between those two views. Beside that I want to include
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 function: The error results
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: Result: EmpID CodepayID Lval1 Lval2 Sum(Lint) Lrmn1 Lrmn2 12450400 649 405480 405485 270320 337900 202740 Answer Use
i need to display customer’s first name and last name who have made the most number of booking. Using select
So using this table i have to display customers F Name and L name, so I tried using (Group By) but didn’t work Answer It sounds like you just need the name of the person with the highest value Bookingtotal. You don’t specify your RDBMS, however Your specific database might use limit instead of top; you can also use with
How to select max and min of 1 column based on other 2 columns?
I’m trying to get the max and min date values in column C based on the (column A, column B) unique pair combinations. Suppose I have a table like: The output I want to get is: My attempt query has been taking 20 mins to run with no output yet (just tried to get max date from column C for
How to calculate Total transactions amount column with input / output type?
I have two tables : (transactions and Accounts) their columns are as shown in the picture bellow: the Accounts table is simple just two columns ID and account name. The important columns in the Transactions table are Amount and type, the type indicates whether the transaction is an input to the account or an output. I want to find the
SQL – how to remove whole row if one of the column in subquery return NULL
I am stuck in 1 SQL query This query return 4 row ( As shown in the screenshot ) I want a scenario like : If subquery return NULL , then the whole row will not be shown. So in this example “childthree” should not be shown , as “parent_user_email” is NULL , so the whole 3rd row need to