I am trying to join table A with table B and I have diabled legacy sql in google big query and the query is running perfectly find. When i run it in the Ipython notebook, it does do so. Just wondering whether there is a command to disable legacy sql from ipython notebook. Any help would be appreciated.
I tried with the below code but it does not get through.
#standardSQL
SELECT A.Id, Latitude, Longitude
FROM
Data AS A
JOIN
T12 AS B
ON
A.StartTime <= B.DateTime
AND A.StopTime >= B.DateTime
AND A.HardwareId = B.HardwareId
WHERE
(A._PARTITIONTIME BETWEEN TIMESTAMP('2016-11-24')
AND TIMESTAMP('2016-11-24'))
AND A.Id = 331
Related
I have a requirement to move SSRS Snapshot data from one report server to another. I found a way to export the snapshots using PowerShell, but I do not see a way to import the data from there.
Thanks for the help in advance!
This SQL statement shows the snapshot data, but it appears that the data is being streamed into a BLOB in the Segment table.
select * from [dbo].[SnapshotData] SD
join dbo.History H
on h.SnapshotDataID = sd.SnapshotDataID
join dbo.Catalog C
on c.ItemID = h.ReportID
join dbo.SegmentedChunk SC
on SC.SnapshotDataId = SD.SnapshotDataID
join dbo.ChunkSegmentMapping CSM
on csm.ChunkId = sc.ChunkId
join dbo.Segment S
on s.SegmentId = csm.SegmentId
where 1=1
order by
c.Path
, sd.CreatedDate DESC
I've encountered a problem with PostgreSQL in Grafana when im searching for name in my DB with accents.
PostgreSQL doesn't search for those names and they don't apear in my dashboard, does anyone knows a way to work arround this problem?
Select vgtuser, count(*)
From (
SELECT DISTINCT(a.ticket_id), max(a.updated_on), b.name as vgtuser
FROM ticket_messages a
INNER JOIN admins b ON a.admin_id=b.admin_id
INNER JOIN ticket_status_history c ON a.ticket_id=c.ticket_id
WHERE a.updated_by in('Ana Monteiro', 'Nuno Gonçalves', 'Henrique Espinha', 'Ricardo Sousa', 'João Fernandes', 'Pedro Pereira', 'Luis Moreno', 'Gonçalo Rodrigues', 'Nuno Coelho') AND c.status_id IN(50, 60, 65)
GROUP BY a.ticket_id, b.name
ORDER BY 1 ) as media
group by 1
ORDER BY 2 desc
To be more precise the names that dosent appear on grafana display are "Nuno Gonçalves" , "João Fernandes", "Gonçalo Rodrigues" all the other names are appearing great, i tried working around the problem using the LIKE clause but the results were not correct and i couldn`t get it to work properly.
For almost a year, I have been using this sql to report on the rank of game profiles, based on the number of days that a game has been above the rank of 10:
SELECT P.id, P.name, P.rank, COUNT(P.id)
FROM application_classes_models_gameprofile P
LEFT JOIN application_classes_models_gamedeveloper D ON D.id = P."developerId"
LEFT JOIN application_classes_models_gameprofileposition PP ON
PP."gameProfileId" = P.id AND
PP.position <= 10 AND
PP.position > 0
WHERE
P.inactive = false AND
D."excludeFromRanking" = false AND
P.rank <= 10 AND
P.rank > 0
GROUP BY P.id
ORDER BY COUNT(P.id) DESC
Grouping is always a big of a pain in postgresql, but the above sql has been working fine for almost a year, returning the expected results.
Yesterday, I had an issue with the game profile table which forced me to have to restore a backup, for that table. I did so using pg_restore -v --clean -t application_classes_models_gameprofile < backup.bak.
This morning, when we ran our reports, postgresql came back with the error:
column "p.name" must appear in the GROUP BY clause or be used in an aggregate function
Just to clarify, this sql has been running for almost a year, and the above error has never appeared for this specific sql query, however, it seems that after we have cleaned and restored the game profile table we're getting the above error...
I know that I can solve the problem by fixing the sql query to remove the name/rank, but I worry if there is a deeper issue here... so does anyone know why the above might happen?
Postgresal version is 9.6, running on debian 9
We are beginning to use Amazon Redshift for our reporting purposes. We are able to load our entire data onto Redshift through S3 and also manually update the data for everyday incremental load. Now we are into the process of automating the entire process because then the scripts can be run at a particular time and data gets automatically updated with everyday data.
The method we are using for incremental load is as suggested in the documentation,
http://docs.aws.amazon.com/redshift/latest/dg/merge-create-staging-table.html
this works fine manually but while automating the process, I am not sure how to obtain the primary key for each table based on which the existing records are updated. In short how to obtain the primary key field from redshift ? Is there something like "index" or some other term which can be used to obtain the primary key or even the distkey ? Thanks in advance
I'm still working on the details of the query to extract the information easily, but you can use this query
select a.attname AS "column_name", format_type(a.atttypid, a.atttypmod) AS "column_type",
format_encoding(a.attencodingtype::integer) AS "encoding", a.attisdistkey AS "distkey",
a.attsortkeyord AS "sortkey", a.attnotnull AS "notnull", a.attnum, i.*
FROM pg_namespace n
join pg_class c on n.oid = c.relnamespace
join pg_attribute a on c.oid = a.attrelid AND a.attnum > 0 AND NOT a.attisdropped
left join pg_index i on c.oid = i.indrelid and i.indisprimary='true'
WHERE
c.relname = 'mytablename'
and n.nspname='myschemaname'
order by a.attnum
to find most of the interesting things about a table. If you look at the output, the pg_index.indkey is a space delimited concatenation of the primary key columns (since it may be a compound key) expressed as the column order number which ties back to the pg_attribute.attnum column.
I have following issue in my drupal site which is postgresql db connected
When i export data to csv using following query it is taking longtime to export into csv
SELECT DISTINCT(a.*),
c.nid,
b.uac_inst_campus_cricos
FROM uac_export_coursetable_latest AS a
LEFT JOIN uac_institutiondata AS c
ON c.uac_institutiondata_institution=a.uac_course_institution
LEFT JOIN uac_inst_campus_latest AS b
ON b.nid=c.nid
AND b.uac_inst_furtherinfobox_heading=a.campusname
WHERE a.uac_course_institution = '%d'
AND intyear12 = 'Yes'
ORDER BY uaccoursecode