Azure Data Studio - Import file wizard not showing newly created schema
See also questions close to this topic
SQL - How to query values that are greater than the value appeared on the first day of usage?
I have the following (table).
"customers_dishes" id - customer id, STRING date - date of arriving at the restaurant, DATE bill - total bill, DOUBLE
I am trying to output all of the incidents of customers that their bill was greater than their first date visiting the restaurant bill
id, date, bill Alen, 2018-03-01, 50 Alen, 2018-03-02, 48 Alen, 2019-03-01, 60 Bob, 2018-03-04, 45 Bob, 2018-03-06, 55 Bob, 2019-03-01, 50
the output should be:
id, date, bill Alen, 2019-03-01, 60 Bob, 2018-03-06, 55 Bob, 2019-03-01, 50
Tried doing something like that:
SELECT (*) FROM customers_dishes WHERE date NOT IN ( SELECT date FROM customers_dishes ORDER BY id, date ASC LIMIT 1) AND id NOT IN( SELECT id FROM customers_dishes ORDER BY id, date ASC LIMIT 1)
Any suggestions please?
I need to get the delta between the date of first payment and user registration date by user
I have two tables: payments, users.
id regtime 2271 2020-01-17 16:38
user_id datetime 2271 2020-03-20 15:11
I need to get the date of the first payment for each user from the table
paymentsand registrations dates (from the table
users) of the same users and count a distinction for each of them in days and if it is possible in hours as well.
That means we will get the time in days and hours of user's life on a platform before they make the first payment.
The output should looks like a table with three columns:
user_id, full_days_before_first_payment, full_hours_before_first_payment
I've already got the first part of a query that returns the list of
user_idand appropriate first payment date:
SELECT user_id, DATE(MIN(datetime)) as First_payment FROM payments GROUP BY user_id
SQL Server : moving millions of rows from one view to another table
I have a table with 1 million rows and it has binary data stored in a
I am joining this with a table with 3.6 billion rows and get 1 million rows and join to the same table twice and was able to get the records and columns I needed. The values are unique, so I didn't use the group by clause. Based on this, I created a view.
Now, I need to append the 1 million records to an existing table in the same database.
How can this be effectively achieved?
I tried SQL Server import/export wizard to append the data and 100000 records it took like 60 mins. 1 million records gets transferred in 10 hours.
How can I make this data move more efficient?
How to bring the same functionality in Azure SQL Databases that works on On-premises in Single Click
As there is a saying/proverb that 'Nothing is impossible', Just Curious to know the way that we can get the same functionality in Azure SQL Databases that works on On-premises in Single Click?
At a single click of execution, With the help of 'USE' Command, we actually query the things in different databases. eg.,
USE db_name1; SELECT DB_NAME(); GO USE db_name2; SELECT DB_NAME(); GO
With the help of Query-->SQLCMD Mode, we actually query the things in even different server and databases. eg.,
:CONNECT server_name1 USE db_name1; SELECT @@SERVERNAME; GO :CONNECT server_name2 USE db_name2; SELECT @@SERVERNAME; GO
Note - for example, i have mentioned some db and server name functions. In actual, will query tables to get required info.
Since, 'USE' Command wont works in Azure SQL Databases. How to achieve the same in Azure SQL Databases - At a single click of execution?
Creating time parameter in SSMS 2016 for SSRS report
I'm trying to create a SSRS report that allows users to search work orders by time range in addition to date. For example: requests from 5/1/20-5/27/20 that took place between 5:00 p.m. and 7:00 p.m. Below is my stored procedure from SSMS 2016, I commented out the time parameters since they're not working. This produces the unrefined data I need and the date parameters work, it's the time parameters I'm having issues with.
@STARTDATE DATE, @ENDDATE DATE --@STARTTIME TIME, --@ENDTIME TIME AS SELECT [PROBLEMCODE] ,FORMAT([DATETIMEINIT], 'yyyy-MM-dd') AS 'DATE' ,FORMAT([DATETIMEINIT], 'hh:mm tt') AS 'TIME' ,[STATUS] FROM [Cityworks].[azteca].[REQUEST] WHERE REQCATEGORY IN ('WATER', 'SEWER') AND [DATETIMEINIT] BETWEEN @STARTDATE AND @ENDDATE --AND FORMAT([DATETIMEINIT], 'HH:mm') BETWEEN @STARTTIME AND @ENDTIME;
This is my first time posting, so I hope all that made sense! Thank you for your help!
How do you use a loop in SQL to compare a record to a previous record?
I am looking at a data set of Emergency Room visits. I only want to keep visits per ID that are 30 days apart. So as an example say I have this below.
If I start with ID=1:
- In Row 1 I can see that the lag between row 1 and 2 is 15 days so I will exclude, or for now flag, row 2.
- Then I will continue to use Row 1 to evaluate Row 3. Again this is only 17 days so I will exclude Row 3 and look at Row 4.
- Row 4 is 30 days away so I keep it and then use Row 4 to evaluate Row 5....and so on.
I have been trying to do this with the lag function but I can't figure out how to utilize the lag when I have to continue to use the 'anchor' row to evaluate several rows.
Top is what I have and bottom is what I want. Any ideas?
I am using AZURE data studio.
Row# ID DATE 1 1 1/1/2020 2 1 1/15/2020 3 1 1/17/2020 4 1 2/4/2020 5 1 3/15/2020 6 2 1/15/2020 7 2 3/15/2020 8 2 3/18/2020
Row# ID DATE 1 1 1/1/2020 4 1 2/4/2020 5 1 3/15/2020 6 2 1/15/2020 7 2 3/15/2020
Azure Data Studio: Save As CSV with header
I saw the article on how to save the result of the query as csv. Is it possible to save it with header?
Reference: Azure Data Studio: Save As CSV
Declaring PROCEDURE with dynamic variable based on user input
IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE SPECIFIC_SCHEMA = N'dbo' AND SPECIFIC_NAME = N'Reports' AND ROUTINE_TYPE = N'PROCEDURE') DROP PROCEDURE dbo.Reports GO CREATE PROCEDURE dbo.Reports (@Date_of_Purchase DATE) AS BEGIN SELECT o.O_Id, o.Sale_Price, o.Private_Band, c.Type, c.Points_Issued, o.Date_of_Purchase FROM Order_Details o LEFT JOIN Transaction_Historys c ON o.Date_of_Purchase = c.Date_of_Purchase WHERE o.Date_of_Purchase > @Date_of_purchase END GO EXECUTE dbo.Reports GO
I want to make
o.Date_of_Purchase > DATEADD(d,@date,getdate()).
@dateshould be dynamic values based on user input, how to declare the days(
I get an error when executing the stored procedure:
Must declare the scalar variable