I am seeing duplicates in my data after running my sql query, and have figured out the issue stemming to our data team not updating a table but adding a new row instead. In this instance, I need to use the largest LD_SEQ_NBR to get the latest data. Given the following table — ORDERS What do I need to ad…
Tag: sql
select distinct and autoincrement field in select query
I have a table Product with So i need a select query that will display distinct product no with ids for displaying in p-listbox. say How do i achieve this? Thanks Answer One method is: That said, I would probably use group by:
How to check if several values are in a list in BigQuery
Is there a way to make this clause more compact? SELECT campaign ,event_list FROM `adobe_analytics.raw_data_20200*` WHERE campaign IS NOT NULL — What does it mean when a campaign is null in …
joining temporal tables in oracle
I am looking for better solutions to a fairly generic problem with temporal tables. say we have table_a (some_value int, date_from date, date_to date) and a series of similar tables table_b, table_c, …
Get the data from previous month in sql query
I have a data of all the cost for each month. For example, I have table of cost for each month +——–+——–+—–+——–+——–+ | Jan | Feb | Mar | Apr | May | +——–+——–…
strftime() with not giving the correct results
I have this table: I need a way to only show records besides the current month and year. example: today is 2021-01-08 I only need to see records besides month 01 and year 2021 This is my sql fiddle playground I do not understand why it doesn’t output the result I want. I need it to show me this: Answer
How to combine two queries? MySQL
How can i combine my two queries? 1: This query is finding dialogs where more than 10 messages and lasted more than an hour. 2: The second query selects two last rows for each dialogs. So, what i want is select last two rows for each dialogs that lasted more than an hour and where more than 10 messages. I
Microsoft SQL Server , view transformation
Is it possible to transform the following view : to this structure ? I’ve tried with cross join but I have no idea how to make a condition based on column name. Answer You need APPLY instead of JOIN to be able to access outer columns
SQL query to unpivot and union for multiple column
I’m trying to achieve the following result… input, table A I would obtain this output I’m trying to use cross apply and I can create the column “month_year” but I don’t know how to merge “values” in the last column. Thanks for help! Answer I think this is basica…
MySQL how to search a JSON field for all rows that intersect with JSON values
Assume that I have a MySQL table with a JSON field, with the structure & values shown below: I would like to get all rows that have ANY of the JSON values that match in a SELECT query. For example: This yields 2 rows: However, I would like it to yield all of the rows, because every row has at