Skip to content
Advertisement

Tag: sql

Case on Join condition

I have a two tables data as below table1: Order orderitem value O1 B-IV122 10 O2 B-IV144 10 table2: order Productionorder productionitem …

fetch id who have register all adv

There are 3 types of adventures for which I used distinct function in query. There is only one 1 customer who have booked all types of adventures. The query i used to fetch the data is: Answer You can get the customer ids using aggregation and having: Or, if you don’t want to hardcode the “3”, you can use: I’ll

Query by a specific month when you only have start and end dates

I need to query a MS SQL table of events by a specific month. In this scenario, I want to return all events which took place during May 2020. I would expect to return ID’s 1, 6 and 9. I’m finding this query quick tricky, so thanks in advance for any help. Answer This article explains why you can use

Best way to ignore null values in MYSQL

My data looks like this, I have multiple values in the Table field with each having its own unique values for the Data field. However, Data values for TableA will be the same format in the table …

How to mimic sql statement logic in cfml / coldfusion?

I Am coming to a problem where I am trying to convert my sql statement to do the same logic in cfml (cfscript>) so, I am trying to mimic this sql statement to display the results inside my cfscript. can somebody help me solve this issue? thanks for the help. SQL: Answer @Scott, I am assuming that: Each row from

SQL Server Grouped Number Generation

I need a way in a SQL Server query to generate grouped numbers when the data switches from one specific data value to another. Based on the first two columns below and how they are ordered, how can the query generate the numbers in the third column? When the Type column changes from Prim to anything else, all the records

INSERT SELECT statement with only one column for SELECT

I’m using SQL Server Management Studio 18 and I’ve got the following tables with the following columns: TableA TableB I want to do an INSERT SELECT into TableB, maybe something like the following: Basically, I just want to make an INSERT SELECT where I’m grabbing a column from another table (InternalEmplID), and then for the other columns (Month and Year),

Advertisement