select groupid,count(value) as x from test_distinct_count group by rollup (groupid); This query gives output like : What i need is to display the value 5 for all the groupids in a column say Total. …
Tag: sql
Postgresql update specific fields based on a value (trigger)
I am writing a Trigger in Postgresql to update dynamically the content of specific columns of a revenues table based on inserts on a consultations table. [edit] Here is how my tables look like …
VPD Policy Function
I’m new to oracle security and I have a question about Virtual Private Database: Let’s assume i have the following table which is called “Payroll” created by a user called “PCM” EMP_ID …
Writing SAS dates to SQL Server databse
How to write SAS dates to Microsoft SQL Server 2016 Date data type in database? I got SAS data with a sas date DataEndDay and I want to write that into a database. The following bit is in use (buffer is just to speed up the testing-failing) : Of course because SAS dates are numbers, direct writing is going to
Mysql Procedure Syntax change to Firebird Procedure Syntax
I don’t know what’s different about the stored procedure of firebird syntax. MySql Procedure: How can I change this one syntax for Firebird stored procedure? Answer The equivalent in Firebird PSQL syntax would be simple assignment, so GEN_EXCEPTION_FROM = PSHIFTDTEFROM; See also Assignment Statements in the Firebird Language Reference. The full equivalent of the fragment shown in your question would
Why CAST from Date time to varchar works in one Environment but not the other?
For this questions, we have two environments, Dev and Prod with both running sql2014 with dev being a developers version and prod an enterprise version. Dev is running the below version(s) Prod is …
SQL Pivot String Data
I have a tables in SQL Server: Product Product Table: This is the output that I need: An ImageID can have maximum 3 ProductID It is not necessary that all ImageID will have 3 products [eg. ImageID=3] Answer Your were very close, you just needed to incorporate Row_Number() Example
Very slow (12+ hours) large table joins in postgres
I am struggling to optimize a simple LEFT JOIN against two very large tables that so far has been taking > 12 hours to complete and ongoing. Here is the execution plan: Gather (cost=1001.26…..
Why does adding ORDER BY drastically speed up query?
I’ve discovered some very strange and counter-intuitive behaviour in PostgreSQL. I have a query structure as follows. I am selecting both the IDs and the count from a subquery. The subquery does the …
My query with to / NOT IN () clause not returning any values?
I have a table with the following data: Value_ID VALUE CODE HR DATE TYPE 1 0 REG 01:00AM 1/1/18 HI 2 4 REG …