Snowflake में Data Types और Functions
Jake Roach
Field Data Engineer

तुलना ऑपरेटर हमें कई मानों की तुलना/मूल्यांकन करने में मदद करते हैं
=, क्या दो मान equal हैं?!=, क्या दो मान not equal हैं?<, क्या एक मान दूसरे से less than है?>, क्या एक मान दूसरे से greater than है?<= or equal to से less than>=, or equal to से greater than$$
true या false रिटर्न होता है!
$$
1 = 1, -- true1 != 1, -- false1 < 2, -- true1 > 2, -- false1 <= 2, -- true2 >= 2 -- true... WHERE 1 = 1 -- Filter records
SELECT
<#> + <#>, -- 2 + 2 -> 4
<field> - <#>, -- 4 - 1 -> 3
<field> * <#>, -- 3 * 2 -> 6
<field> / <#>, -- 9 / 3 -> 3
...
# और field के किसी भी संयोजन के बीच किए जा सकते हैंअरिथमेटिक ऑपरेटर हमें न्यूमेरिक मानों पर "math" करने देते हैं
$$
+, addition-, subtraction*, multiplication/, divisionSELECT student_name, exam_score,exam_score + 10 AS add_points, -- हर छात्र के ग्रेड में 10 पॉइंट जोड़ेंexam_score * curve AS curved, -- ग्रेड को 10% से कर्व करेंexam_score / 2 AS weighted -- टेस्ट का वेट आधा करेंFROM STUDENTS.grades;
student_name | exam_score | add_points | curved | weighted
-------------- | -------------- | ------------ | -------- | ----------
Ryan | 78 | 88 | 85.8 | 39
Tatiana | 89 | 99 | 97.9 | 44.5
Pankaj | 74 | 84 | 81.4 | 37

SELECT<1>,SUM(<field>), -- एक कॉलम का कुल देता हैAVG(<field>) -- एक कॉलम का औसत निकालता हैFROM ...GROUP BY <1>;
नॉन-एग्रीगेटेड फील्ड्स को GROUP BY करना अनिवार्य है!
GROUP BY ALLSELECT exam_name, SUM(correct_answers) AS total_correct_answers, -- कुल # सही AVG(exam_score) AS avg_exam_score, -- औसत एग्जाम स्कोरROUND(AVG(exam_score), 1) AS rounded_exam_score -- ROUND(<value>, <n>)FROM STUDENTS.grades GROUP BY exam_name; -- रिकॉर्ड्स एग्रीगेट करने के लिए GROUP BY, वरना error
ROUND() एक मान को राउंड करता है, और दशमलव के बाद रखने वाली अंकों की संख्या लेता है
exam_name | total_correct_answers | avg_exam_score | rounded_avg_exam_score
------------- | ----------------------- | ---------------- | ------------------------
Calculus I | 871 | 89.11111 | 89.1
Biology | 776 | 87.47777 | 87.5
English III | 541 | 91.33333 | 91.3
Python | 1179 | 92.78787 | 92.8
Finance | 349 | 96.14156 | 96.1
मान इनसे जनरेट हुए:
SUM(correct_answers)AVG(exam_score)ROUND(AVG(exam_score), 2)Snowflake में Data Types और Functions