Skip to content
Advertisement

check date in create table sql

edit: version 8.0.20 I’m learning sql just now, I try to fix it but I’m not able to do it. I have 3 table This is an easier scheme but it’s enough. The return_date must be less than delivery_date + 30 days I tried to use a check on return_date but no work, so I created a view to select

Optimize Query Mysql to count data in each district

i have this query for calculate success total in each district. this query works but its take until 2min to output data, i have 15k rows in orders. the output should be like this can you help me to improve the peformance? Thanks Answer Try performing the grouping/calculation in a joined “derived table” instead of a “correlated subquery” “Correlated subqueries”

How do I create cohorts of users from month of first order, then count information about those orders in SQL?

I’m trying to use SQL to: Create user cohorts by the month of their first order Sum the total of all the order amounts bought by that cohort all-time Output the cohort name (its month), the cohort size (total users who made first purchase in that month), total_revenue (all order revenue from the users in that cohort), and avg_revenue (the

How to list data from join table in one row?

There 3 entities: 1) Question, 2) Tag and join table between them – question_has_tag. When I make a select query like: I’m getting the following result: and I needed to get: How to get it ? Answer You need to GROUP them and use GROUP_CONCAT Like

MS SQL Server Date Month Output

SQL will output a month part as a number but I’d like to out put the 3 char version (Jan, Feb, Mar etc) My query thus far is Answer For each DBMS the way is different Here are few 4 DBMS’s MS SQL Server MySQL Postgresql Oracle So in your case use the appropriate date field instead of current date

SQL Case Order By specific order and Direction

I have a table that I need sorted on fields By @SortBy and @SortDirection, for ID,PriorityID,stateType (column type is int) result is OK, but for Title (nvarchar) Query Result is: Conversion failed when converting the nvarchar value ‘Title Column value’ to data type int. Query: Answer The types are different, and that is a problem for the case expressions. The

Advertisement