Skip to content

Tag: sql

Define a temporary table within an SQL “select” query

I’m referring to MS Access SQL. Suppose I have a column with dates of birth of a population and the decades which these dates fall into. I want to create a query which will show how many people were born in each decade of a century. I know it’s going to be something like My problem is that there m…

Translate SQL statement in R code using dplyr

I need help transalting an SQL statement regarding this dataset https://www.kaggle.com/datasets/hugomathien/soccer , into r code using dplyr. The SQL statement is : The r code that i have tried is: and i get this error : Error in dplyr::common_by(): ! by required, because the data sources have no common varia…

Return distinct results that appear more than once

I have the following data: Result should be: Note that the result find unique combinations of ID and Site that repeat more than once for a given ID. I did the following query but does not return the result: Answer See: DBFIDDLE The SELECT ID, site FROM table1 GROUP BY ID, site will select the distinct values.…

DATEPART and DATEFIRST alternative for redshift

I’m trying to run in Redshift with the start day being Saturday. I tried using different syntax for SET DATEFIRST but it seems like it’s not supported (or I just can’t find the correct syntax for redshift). Are there any alternatives available? The documentation page only shows information f…

query to get statistic data from SQL server

I have a table named total sales. In this table there are sales data like invoice date and branch name that sells the invoice and the quantity. I am trying to make a query to get total sales for each branch in every single date and my code is below, but when I execute the code the query returns an

Search in the database

This Messages form display table with these informations (ID,FROM,TO,TITLE,MESSAGE). I am trying to search for all the messages send to a certain user . user will enter his name in the Search_textBox then it will filter the table to keep only messages to this user. I get this error : Answer this is Correct