I’m really new to SQL and quite struggling with this. I have 2 tables MATERIAL (CODE, NAME, BUYPRICE) BILL (CODE, DETAIL, AMOUNT) I want to return a new temporary column TOTALMONEYTOPAID which is BUYPRICE * AMOUNT. Query: This obviously doesn’t work. I searched around for something like declare @variable but I don’t know how to use it. Many thanks with
Tag: sql
Loop runs until the condition is met but insert statement is being used only once
I am trying to create an Expense Management system where I will be able to schedule future expenses if the user selects frequency like daily, weekly, monthly etc. To achieve this, I have created a …
SQL: Create an extra column with last 3 days date as a value
I have a table(users) with these sample data user location name 111 usa aaa 222 canada bbb 333 usa ccc 444 mexico ddd 555 japan eee …
Postgresql: how to calculate the percentage correctly?
With this very simple query I obtain the count(total) and genre of movies from my db. select genre,count(*) from titles group by genre order by count desc; genre | count —————–+-…
Get the logs of the current week in postgresql
I need to get the logs of the current week in postgresql, I have tried to use the native mysql functions yearweek for that, but here in postgresql it is different This is my table CREATE TABLE …
Calculate percentage using SQL
I am trying to find how I can calculate Percentage from table below From the above table, I am hoping to get the data with percentage like below. However my SQL statement below returns all percentage …
Retrieving specific column data from SQL sub-query
My goal is to pull out the values shown in red in the picture. I used this query to pull the data together. The rows are associated via ActionID and filtered with the ‘AND’ conditions shown. SELECT […
How to extract list of values from JSON in SQL Server
In a SQL Server database, I have a table that contains 2 columns, ID and JSON. The JSON column contains JSON-formatted text. I have access to ISJSON, JSON_VALUE and JSON_QUERY, but not OPENJSON. I am …
Azure Stream Analytics Job delayed output of not matching records by 1 minutes between two event hubs
Could anyone help me, why the not matching records are delayed by exactly 1 minutes but the matching records are writing into blog storage container immediately. Is there any way to avoid the delay even though eventA its not matching with other eventB (being my downstream system will take care in my use-case) Below is the output but look at
T-SQL Convert Arithmetic Formula into its Components
Problem Statement: I have a Formula column that has the arithmetic operation in it. I want to extract the variable names from the formula, and delimit the variables with a comma and create a New …