Category "sql"

Viewing SQL queries from all sources

I found this picture in a document. It shows the queries running on a given SQL database. It looks similar to DBeaver software. However, I couldn't find a way t

How to solve this Python error when inserting list in database?

I'm trying to insert into database a list (that I extracted from a file) with 3 columns: log_time log_type message I used this code: #database connection try:

How to rank for this query

I want to generate the below result and here is my query SET @count:=0; SELECT Workout.created_by, SUM(Workout.training_load) as TL, FB_User.name from FB_Worko

SQL Pivot with Text Values

First question posted here so apologies if it is the wrong place! I'm attempting to pivot data in SSMS based on the below sample data that i have as an example

How to select distinct on "name" using Sequelize?

I need to translate the postgresql query below select distinct on (name) * from users To seqelize query / condition . Currently I am just selecting all users f

How to create mysql data with specific CSV file strings

I have csv file which has data as in following format(data has converted from rrd to csv) ..... ...... <database> <!-- 2022-04-26 22:04:00 +0530 /

How do I convert from 5 digit number date in PHP? [duplicate]

I tried to import an Excel file in the database,but the dates are shown as 5 digit numbers 44605 representing 2/13/2022.What can I use to conv

SQL Segmentation

I have this table Customer Amount Date Period Group 77766 50 2022-02-28 1 2 77766 20 2022-03-31 2 2 77766 30 2022-04-30 3 3 12345 50 2022-02-28 1 1 12345 20 20

SQL CROSS JOIN with WHERE CLAUSE not returning anything

I am trying to get a result for the query: SELECT product, exportcountry FROM is_exported_to CROSS JOIN is_produced_in WHERE product = cheese AND origin = 'Fran

Adding constraint to check if the value contains specific characters- SQL Server

My Check constraint conflicts when adding values, any answer to why it is wrong will be much appreciated. Here is the question: Ensure that the Student’s

How to retrieve data from previous 4 weeks (mySQL)

I am trying to write a query to get the last 4 weeks (Mon-Sun) of data. I want every week of data to be stored with an individual and shared table. every week d

Sql function to remove values from follower table that are common in unfollow table

I want to calculate total followers of a person from follow and unfollow table using SQl. Form of table are as follows Follow table: Unfollow table: My tries:

Tuning slow query to SYS tables

I'm monitoring the slowest queries to my databases and this one can't be indexed: USE [Project] SELECT TOP 10 t.NAME AS TableName, t.object_id, mai

How to generate an equivalent of pandas.DataFrame.describe in bigquery SQL?

In Pandas, you can get an overview of the table (mean, quantiles, count and count of unique values) for all columns by using the following method: pandas.DataFr

row_number is not unique for duplicate records

I am trying to find the latest update of a particular row from a bunch of rows per uuid. For that we use row_number() over a partition as shown below, "row_numb

Query to show data checkin , checkout, breakin breakout in 1 row

I have structure data like this, I'm using SQL Server: ID User_ID CheckinTime Date 1 110 "2022-03-25 06:30:29" "2022-03-25" 2 110 "2022-03-25 12:12:31" "2022-

Query to show data checkin , checkout, breakin breakout in 1 row

I have structure data like this, I'm using SQL Server: ID User_ID CheckinTime Date 1 110 "2022-03-25 06:30:29" "2022-03-25" 2 110 "2022-03-25 12:12:31" "2022-

Migrate data from multiple columns of table to only one column of oher

Is there any way to migrate multiple columns data of table to only one column of other? I need to migrate the data of table 1 subject varchar(45) body

Find which where clause is the most troublesome

Problem background I am trying to pin down to what condition(s) are causing no records / rows the most, so to allow me to find the root cause of what data in th

How do I set up an SQL table to save week days and time in each event record

I'm looking for the efficient way to store week days and times of each event. How do I achieve the following result Events table id name dates rel_id 1 hello w