Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question How to convert a string (43677) to date in SQL(Redshift)? (I’m trying to convert strin…
what is the query in oracle sql to find product orders before a certain date?
how do i find all the customers who have made orders before 2017. List must incld the customer ID, customer name, and ordered by their ID values in desc Answer You can use exists and a correlated subquery to filter customers who ordered before 2017. We can get that information by looking at the orders table o…
How do I copy a column from one table to another table in sql
two tables region(region_id,region_name) countries(country_id,country_name,region_id) there are many country_id and country_name in countries table with region_id given multiple times to those countries ( region_id are only 4) I need to create a table or view where it shows region_name and number of countries…
Select current week, starts from Monday instead of Sunday
I’ve managed to select the data from the current week but the week itself starts from Sunday which is not the right format for me, it should starts from Monday. I’m using MySQL to query the data. Answer You can use this little formula to get the Monday starting the week of any given DATE, DATETIME…
Aggregate function not accepted inside WHERE clause
I have the following command. With this PostgreSQL schema. After adding AND day_of_week=3 to WHERE I get the following error. Why cannot I restrict this column? Answer You cannot use a derived column in a where clause. A simple solution is a lateral join: Some advice: Do not use NATURAL JOIN. There is nothing…
Query to get grandparents and grandkids
I got a table people: ID name surname mother_id father_id ——————————————– 1 John smith null null 2 kate m null null 3 …
Query BETWEEN TWO TABLES OUTPUT (MYSQL)
two table EMPLOYEE and Department EMPLOYEE’s fields are ID,Name, Salary ,DEPT_ID(foreign key to department table) DEPARTMENT’S fields are id,NAME,LOCATION VALUES OF EMPLOYEE TABLE WILL Be Values OF DEPARTMENT TABLE WILL BE Output from these table should be DEPARTMENT_Name should be alpabetically w…
Map results from one table to different columns in another query
I’m trying to retrieve a set of records from table that has descriptions on another table in same database. Table 1: ColA1 | DescrpA1 — A – – – – Apple — B – – – – Orange — C – – – – Banana — D – –…
Compute a Decreasing Cumulative Sum in SQL Server
What I’m trying to achieve is a cumulative sum on a non-negative column where it decreases by 1 on every row, however the result must also be non-negative. For example, for the following table, summing over the “VALUE” column ordered by the “ID” column: I expect: Answer Your ques…
Is there any way to avoid double quotes around an URL in R?
I am trying to pull data using an API call with GET from httr. The API call has SQL statements that require double quotes around table and field IDs, and single quotes around string values. This means I get some issues when I use the URL in R, because it needs quotes around it there as well. The API call