We have separate table maintained for condition / filters. Based on the conditions, filters to be applied at base table. here’s the sample input conditional data for reference purpose Based on this input conditions , filter to be derived as follows. please help me in achieving the filter query Answer Th…
Tag: sql
Retrieve the first occurrence of a record by ID in SQL
I am trying to import some data into Excel from a SQL server, but I am having some issues. It’s my first time writing a query, although I am able to get the entire dataset, I have realized that the data is full of duplicates. I want to get rid of duplicates in Excel and only keep Unique records. I
Postgresql Select and display one column based on another column
WALLET TABLE ID IS_SPEND HOWMUCH true. 500 false. 1000 true. 5 I want to calculate how much money I have after several transactions. spend as spend money and not spend as earn money I tried But it cannot reach my goal. I don’t know how can I get the result I want, just output 495 is perfect. Answer You …
Joining two queries with different where clauses into 1 table
This is probably a pretty simple question, but I have two separate queries that I would like to join into one table. One of the queries shows sign ups to my website by month and the other query shows sign ups that have made a purchase. I would like to combine the two queries into one table so I have
How to de-duplicate SQL table rows by multiple columns with hierarchy?
I have a table with multiple records for each patient. My end goal is a table that is 1-to-1 between Patient_id and Value. I would like to de-duplicate (in respect to patient_id) my rows based on “a hierarchical series of aggregate functions” (if someone has a better way to phrase this, I’d …
How to get “session duration” group by “operating system” in Firebase Bigquery SQL?
I try to get the “average session duration” group by “operating system” (device.operating_system) and “date” (event_date). In the firebase blog, they give us this query to get the average duration session This query give me the total user engagement by user ID (each row is …
Oracle UNION depending an IF conditon
I have to make a SQL query wraping all of theses statements: First, I have a first SQL query like this: Then, I have another SQL statement like this: Finally, based on the first SQL statement, I have to add a row of fake data on the result of the second statement if NbOfEntries > 0. I have to add
Add child note above node
Am trying to get from SQL to XML however have to format this correctly or it will not work. I am using C# to insert my sql between the QBXML This is what I get This is what I need ”’ ”’ I am not sure how to add the “CustomerAddRq” over each “CustomerAdd” Answer …
SQL select the latest record on joined tables
I want to retrieve the property which an user paid a tax last. have two tables person_properties and property_taxes What I tried so far: This gives me the person_id along the max year. But I actually need the property_id, the property which an user paid last. If I replace pp.person_id by pp.property_id, I the…
Remove multiple instances of the same person, different IDs from SQL Server
I have a data set where there are individuals appearning multiple times with the same name and SSN but different personids. I want to remove those people and only keep those that appear one time. In this instance I only want to return Roman Smith and eliminate John Thomas altogether. I’ve been playing a…