Skip to content

Tag: sql

How to write sql query to get this result

I had two tables as below: request_id update_from_id sw_ref_number raised_by_user_id raised_date 1 0 1 3 2019-08-29 15:08:16.000 id request_id input_id value is_deleted 21 1 1 00001 0 22 1 2 3 0 75 2 1 00002 0 76 2 2 0 My query is: And after that my result is: request_id sw_ref_number value input_id 1 1 00001…

Pulling out monthly daypart data

I’m dealing with sales data that looks like this Date Time Net Amount Store No Item Category Code 2021-03-21 00:00:00.000 1754-01-01 08:01:14.627 100 001 FOOD 2021-01-31 00:00:00.000 1754-01-01 15:42:21.670 120 002 FOOD 2021-04-24 00:00:00.000 1754-01-01 17:35:30.070 160 002 FOOD 2021-03-14 00:00:00.000…

Field value counts with aggregate conditions

Suppose I have the following applicant data for jobs in a company: The budget is 40000 and the preference is to hire senior managers. What PostgreSQL constructs do I use to get the following result as far as the number of hires are concerned. Any directions would be appreciated. Here is a starting sqlfiddle: …

SQL query not returning all possible rows

I am writing a simple SQL query to get the latest records for every customerid. My SQL query – Sample data: customerid device_count date_time A 3573 2021-07-26 02:15:09-05:00 A 4 2021-07-26 02:15:13-05:00 A 16988 2021-07-26 02:15:13-05:00 A 20696 2021-07-26 02:15:13-05:00 A 24655 2021-07-26 02:15:13-05:…

SQL Subquery as expression

I have the following two tables: I want to be able to return all the claims that are a specific FormType and AdjustmentVersion. Given the following query: How do I correct the syntax to match the AdjustmentVersion on the given integers and the subquery at the same time? Currently, I am getting error ‘Su…

Can * be used for partial topics in AWS’ IoT Rule syntax?

Is this allowed as AWS’ IoT Rule syntax?: Answer No, you cannot use a * to achieve this, since you must pass a valid topic filter. According to the documentation you are able to use a + sign to achieve this effect. Quoted from the documentation linked above: A subscription to sensor/+/room1 receives mes…