I have a table: table1 unique_id col_id val_id 1 100 a 1 101 b 1 102 c 1 103 d 2 106 a 2 106 b 2 …
How to fix ‘must be an aggregate expression or appear in GROUP BY clause’ with ‘as’ clause
I am trying to get the number of request by hour of my CloudFront distribution using athena query. I created cloudfront_logs table guided by this Link in my sample_db Below is the query I made to …
How to get unique customer names those have different IDS
I am working with a table that contains Account_No as unique ID, Customer_Name, Building_Name. The table below is an example: It can be seen for few cases there are same customer name and same …
How to denormalized data in SQL query
I have a table that has Clinic Names and Doctor Names. one clinic can have many doctors. I need to split this data into two tables. one with clinic info and the other with Doctor info trying to do …
Create new date ranges from overlapping date ranges and assign an ID
I have the following table ID | START_DATE | END_DATE | FEATURE ————————————— 001 | 1995-08-01 | 1997-12-31 | 1 001 | 1998-01-01 | 2017-03-31 | 4 001 | 2000-06-14 | 2017-…
Why does MS SQL allow you to create an illegal column?
I recently saw a tweet stating that you could prevent other developers from reading from a table using the SELECT * FROM TableName by building your table in the following way: CREATE TABLE [TableName]…
Convert char var to integer for use in join
I am trying to get a report to run through crystal using our postgres databse. My SQL looks like SELECT slcnote.note_date, slcnote.account, customer.name, slcnote.reference, …
VBA Function/ Code – Convert Dynamic Column of Data into Text String
I’m creating a tool where users can query an ODBC through excel. I need a function which will look at a column of item id’s which the user has pasted in and then create a text string which can be used …
MySQL: Select only if field values are ascending
I have two tables: Route and Stop (one to many). And also I have input data: two location IDs which is related to ‘stop’ table. Every route has it’s own ORDERED list of stops. I need to select Route …
How to produce a running sequence in Oracle based on report column values
I have the following sample Oracle APEX report by where the Origin ID and Origin Name are retrieved from the origin_tab(id,origin_id,origin_name) Based on these two column values, I need to generate …