I have the following table that I’m trying to find the total count for each unique name element. The problem is, other: 1 and other: Null are supposed to be different elements, but my query is grouping them together. The issue I’m running into is that null is not being counted as a row. But when I…
Tag: sql
Azure hosted SQL: show all fields in a table as a saved View
Probably a simple answer, but assume I have a table with 3 columns: I create a new view It works. I save the view, SSMS automatically changes the saved version of the view to say: How do I keep the saved version of the view to include all columns in tbl rather than explicitly identifying each column? Answer Y…
Make SELECT subquery COUNT the total subscribers of a subscriber
I trying to create a query that counts the total subscribers of a subscriber. It currently looks like this: The FROM CLAUSE AKA all_users_subbed_to is WORKING correctly and displays a ALL the subscribers the current user has. The data comes back as this: The issue I am having is getting the total subscriber c…
display details of employees who joined in first march of each year [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 9 months ago. Improve this question In m…
Calculating the moving average in Vertica for all stocks
I have a stocks table for example: I want to calculate moving average for all the stocks with a single query in Vertica. This is the way to do so for only one stock (according to Vertica website): Output: If I try to select all the stock: I am getting a wrong result. How can I fix that? Answer Add
How to compare two row in same table and return the data in response using stored procedure
I have to compare between two rows using two Id’s in the same table, and I want to get the columns and their values that are not matching in the stored procedure and I need to return it in JSON format. Output: I don’t have expertise in it however I tried the below SQL code but I need this in
Find duplicate data in last 1 hour
I am looking for a SQL script to find the data which has more than 2 entries in last 1 hour. I have a table having user_id & event_time. I want a way to find out if the user_id has more than 1 entries in last 1 hour. I have tried below till now: Create temp table to put all
Why is the SSIS variable not passing the milliseconds part into the query?
DB SETUP: SSIS: Execute SQL task: The task has an output parameter (say Param1) of data type DT_DBTIMESTAMP. The SSIS variable data type is DateTime. Then in a subsequent Data Flow Task (say TASK2), I have an OLE DB source SQL command text: The above variable is used as an input parameter. In the SQL profiler…
how to divide each row by the sum of those rows?
I have a table CREDITS with these columns: DAY_OPERATIONAL TOTAL_LOAN CREDITS_PERCENT I should multiply each row’s TOTAL_LOAN and CREDITS_PERCENT then divide to SUM(TOTAL_LOAN) in that DAY_OPERATIONAL. My code is not working. How can I achieve this? How do I need to use group by properly? Answer This is…
How do I convert this to mongodb aggregate query?
SELECT prop_type , count(prop_type) As no_of_properties from prop_type JOIN prop_for_rent USING (prop_type) GROUP BY prop_type; prop_type and prop_for_rent are both tables. Then “prop_type” used for the JOIN and GROUP BY is an attribute name in both. The expected result is for the query to count t…