Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RFID
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Szymon Langer
RFID
Commits
f9f09fb6
There was an error fetching the commit references. Please try again later.
Commit
f9f09fb6
authored
3 years ago
by
Szymon Pawłowski
Browse files
Options
Downloads
Patches
Plain Diff
Query z full joinem i splitem czasu
parent
b4c1b384
No related merge requests found
Pipeline
#2145
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SQLQuery_fulljoin_timesplit.sql
+56
-0
56 additions, 0 deletions
SQLQuery_fulljoin_timesplit.sql
with
56 additions
and
0 deletions
SQLQuery_fulljoin_timesplit.sql
0 → 100644
+
56
−
0
View file @
f9f09fb6
-- FULL JOIN TABLE WITH ADDITIONAL COLUMNS
SELECT
TOP
1000
*
,
RIGHT
(
t
.
TIMESTAMP
,
12
)
AS
'TIME'
,
RIGHT
(
prev
.
TIMESTAMP
,
12
)
AS
'PREV_TIME'
--LEFT(rfid.TIMESTAMP, 10) AS 'DATE' niepotrzebne, rozpatrujemy tylko 1 dzie
FROM
rfid
.
Logs
rfid
JOIN
rfid
.
EanEpc
ean
ON
rfid
.
EPC
=
ean
.
EPC
JOIN
dw
.
Item
it
ON
ean
.
EAN
=
it
.
EAN
JOIN
dw
.
Subclass
sub
ON
sub
.
SubclassID
=
it
.
SubclassID
JOIN
dw
.
Class
cl
ON
sub
.
ClassID
=
cl
.
ClassID
JOIN
dw
.
Department
dep
ON
dep
.
DepartmentID
=
cl
.
DepartmentID
JOIN
dw
.
Brand
br
ON
dep
.
BrandID
=
br
.
BrandID
JOIN
(
SELECT
TIMESTAMP
,
ROW_NUMBER
()
OVER
(
ORDER
BY
TIMESTAMP
)
AS
'RN'
FROM
rfid
.
Logs
)
t
ON
rfid
.
TIMESTAMP
=
t
.
TIMESTAMP
LEFT
JOIN
(
SELECT
TIMESTAMP
,
ROW_NUMBER
()
OVER
(
ORDER
BY
TIMESTAMP
)
AS
'RN_PREV'
FROM
rfid
.
Logs
)
prev
ON
t
.
RN
-
1
=
prev
.
RN_PREV
WHERE
ean
.
EAN
=
'5902805820577'
AND
ITEMID
=
'2155620'
ORDER
BY
t
.
TIMESTAMP
--
SELECT
MAX
(
PROXIMITY
)
FROM
rfid
.
Logs
rfid
JOIN
rfid
.
EanEpc
ean
ON
rfid
.
EPC
=
ean
.
EPC
JOIN
dw
.
Item
it
ON
ean
.
EAN
=
it
.
EAN
JOIN
dw
.
Subclass
sub
ON
sub
.
SubclassID
=
it
.
SubclassID
JOIN
dw
.
Class
cl
ON
sub
.
ClassID
=
cl
.
ClassID
JOIN
dw
.
Department
dep
ON
dep
.
DepartmentID
=
cl
.
DepartmentID
JOIN
dw
.
Brand
br
ON
dep
.
BrandID
=
br
.
BrandID
ORDER
BY
rfid
.
TIMESTAMP
-- NUMBER OF DISTINCT EANs (ITEMIDs) PER EPC (CLIP (?))
SELECT
EPC
,
COUNT
(
EAN
)
AS
cn
FROM
rfid
.
EanEpc
GROUP
BY
EPC
ORDER
BY
cn
DESC
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment