Skip to main content

Sql-Keywords (distinct , order by) and where clause

 Sql-Keywords (distinct , order by) and where clause

Distinct Keyword


The DISTINCT keyword is used to return only distinct (unique) column values.
Sql tables often contains many duplicate values in columns and sometimes you only want to list the unique(distinct) values.

sample table :


In table we can multiple name with same values.

to view on distinct column value following distinct command to execute

Select distinct empname from k4coding_emp




Distinct Keyword:

The ORDER BY keyword is used to sort the  output  in ascending or descending order.


ORDER BY Syntax
SELECT col1, col2,col3, ...
FROM tablename
ORDER BY col1, col2, ... ASC|DESC;

The ORDER BY keyword sorts the records in ascending order by default. 
Select * from k4coding_emp order by empname




To sort the records in descending order, use the DESC keyword.

Select * from k4coding_emp order by empname desc




The SQL WHERE clause is used to filter the records, it contains logical conditions .
The WHERE clause is used to extract only those records that fulfill a specified condition.

WHERE clause  Syntax
SELECT col1, col2, ...
FROM table_name
WHERE condition;

Select * from k4coding_emp
where dept ='HR'



Comments

Ads

loading...

Popular posts from this blog

India's second spaceport to be in TN's Thoothukdi: ISRO

India's second spaceport to be in TN's Thoothukdi: ISRO second spaceport for launching small satellites would be located in Tamil Nadu's Thoothukudi district, ISRO chief K. Sivan said on Wednesday. "The Tamil Nadu government has begun acquiring about 2,300 acres of land in Thoothukudi district for our second satellite launch port, ideally located for launching smaller satellites in the earth's lower orbit," the Indian Space Research Organisation Chairman told reporters here. Thoothukudi is about 600 km southeast of Chennai. The country's first spaceport is at Sriharikota in Andhra Pradesh, about 90 km northeast of Chennai. "The new location is ideal for launching smaller satellites of less than 500kg in the sun-synchronous orbit," said Sivan. The space agency will outsource making of the small satellites to the private industry. "The smaller satellites will be initially launched from Sriharikota and subsequently to the...

Makar Sankranti 2021

Makar Sankranti 2021 मकर संक्रांति का इतिहास - पौराणिक कथाओं के अनुसार, मकर संक्रांति के दिन की गंगा जी भगीरथ के पीछे-पीछे चलकर कपिल मुनि के आश्रम से होते है सागर में जा मिली थीं। इसीलिए आज के दिन गंगा स्नान का विशेष महत्व है। मकर संक्रांति को मौसम में बदलाव का सूचक भी माना जाता है। आज से वातारण में कुछ गर्मी आने लगती है और फिर बसंत ऋतु के बाद ग्रीष्म ऋतु का आगमन होता है। कुछ अन्य कथाओं के अनुसार मकर संक्रांति के दिन देवता पृथ्वी पर अवतरित होते हैं और गंगा स्नान करते हैं। इस वजह से भी गंगा स्नान का आज विशेष महत्व माना गया है। मकर संक्रांति का महत्व- माना जाता है कि इस दिन सूर्य अपने पुत्र शनिदेव से नाराजगी भूलाकर उनके घर गए थे। धार्मिक मान्यताओं के अनुसार इस दिन पवित्र नदी में स्नान, दान, पूजा आदि करने से व्यक्ति का पुण्य प्रभाव हजार गुना बढ़ जाता है। इस दिन से मलमास खत्म होने के साथ शुभ माह प्रारंभ हो जाता है। इस खास दिन को सुख और समृद्धि का दिन माना जाता है। आमतौर पर मकर संक्रांति 14 जनवरी को मनाया जाती है इसलिए लोहड़ी का पर्व 13 जनवरी को मनाया जाता रहा है। लेकिन बीते क...

what is Binary ? बाइनरी क्या है?

बाइनरी क्या है? कंप्यूटर उन शब्दों या संख्याओं को नहीं समझते हैं जो मनुष्य करते हैं।  आधुनिक सॉफ़्टवेयर अंतिम उपयोगकर्ता को इसे अनदेखा करने की अनुमति देता है, लेकिन आपके कंप्यूटर के निम्नतम स्तरों पर, सब कुछ एक द्विआधारी विद्युत संकेत द्वारा दर्शाया जाता है जो दो में से एक स्थिति में पंजीकृत होता है: चालू या बंद।  जटिल डेटा की समझ बनाने के लिए, आपके कंप्यूटर को बाइनरी में एनकोड करना होगा।  बाइनरी एक बेस 2 नंबर सिस्टम है।  बेस 2 का अर्थ है कि केवल दो अंक हैं - 1 और 0 - जो आपके कंप्यूटर को समझने और चालू करने के लिए अनुरूप हैं।  आप शायद बेस 10 - दशमलव प्रणाली से परिचित हैं।  दशांश दस अंकों का उपयोग करता है जो 0 से 9 तक होता है, और फिर दो अंकों की संख्या बनाने के लिए चारों ओर लपेटता है, प्रत्येक अंक पिछले (1, 10, 100, आदि) से दस गुना अधिक मूल्य का होता है।  बाइनरी समान है, जिसमें प्रत्येक अंक पिछले से दो गुना अधिक है। तो कंप्यूटर बाइनरी का उपयोग क्यों करते हैं?  संक्षिप्त उत्तर: हार्डवेयर और भौतिकी के नियम।  आपके कंप्यूटर का प...

Visits



blog counter