I am trying to create a Python program that will query a URL and produce a JSON file. I need to pass an argument in the end of the URL which comes from the SQL query. I have imported the requests …
Tag: sql
Select by -3 days?
I’m trying to select data from a specific table in my database, but I want to be able to only view the last 3 days worth of data, I have the following code but for some reason I can’t get it to work. Answer You may avoid usage of DATE_ADD() at all: As @OGHaza mentioned, you specified column with a…
Return All Months & Years Between Date Range – SQL
I’m a bit stumped how I might go about this. I have a very basic query, that currently returns sales for each product, by year and month. It is grouping by year/month, and summing up the quantity. This returns one row for each product/year/month combo where there was a sale. If there was no sale for a m…
sql-ex exercise 39 failed on second server error?
Exercise 39: Define the ships that “survived for future battles”; being damaged in one battle, they took part in another. Database Schema: http://www.sql-ex.ru/help/select13.php#db_3 My approach: sql-ex says Your query produced correct result set on main database, but it failed test on second, che…
SQL count of distinct records against multiple criteria
I have a table in SQL SERVER “usage” that consists of 4 columns Now I need to query the table so that I can find how many users used an app under a license within a time frame. Bearing in mind that even if user 1 used the app on say january 1st and 2nd they would only count as
USE database_name command alternative for Oracle
what is the alternative of use database_name command of SQL server in oracle?
PHP SQL Views counter using PDO prepare()
I have a variable $id which gives me the id of the current article and this can help me to make an update query in my database on current article. This is my code: I don’t get any errors but my code is still not working… Answer Your correct code is here: ; from the end of sql is not
Best Practice For Lookup Tables In SQL
I am fairly new to SQL so apologies if this questions sounds odd. I keep coming across the issue of poor data. As an example London could be stored as LON, London UK, London England etc. Prior to …
Concatenate string in statement that assigns a variable in PostgreSQL
I am trying to convert SQL Server procedure to PostgreSQL. In the SQL Server procedure There are statements like below SET @val = ‘(‘ + @someval + ‘)’ So in postgresql I wrote as below SET val …
How do you leave comments in SQL Server 2008 R2 view with SSMS?
According to multiple sources Microsoft , SQL Server Administration Blog | zarez.net adding comments to SQL and doing so with SSMS is a piece of cake. And for the most part they are probably right. But when I log in and create a view I have been unable to leave comments in it. If I use two hyphens (–) t…